Search in sources :

Example 1 with PackageSelector

use of org.junit.platform.engine.discovery.PackageSelector in project junit5 by junit-team.

the class DiscoveryRequestCreatorTests method convertsPackageSelectors.

@Test
void convertsPackageSelectors() {
    options.setSelectedPackages(asList("com.acme.foo", "com.example.bar"));
    LauncherDiscoveryRequest request = convert();
    List<PackageSelector> packageSelectors = request.getSelectorsByType(PackageSelector.class);
    assertThat(packageSelectors).extracting(PackageSelector::getPackageName).containsExactly("com.acme.foo", "com.example.bar");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) PackageSelector(org.junit.platform.engine.discovery.PackageSelector) Test(org.junit.jupiter.api.Test)

Example 2 with PackageSelector

use of org.junit.platform.engine.discovery.PackageSelector in project junit5 by junit-team.

the class TestClassWithTemplate method packageResolutionUsingExplicitBasePackage.

@Test
void packageResolutionUsingExplicitBasePackage() {
    PackageSelector selector = selectPackage("org.junit.jupiter.engine.descriptor.subpackage");
    resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
    assertEquals(6, engineDescriptor.getDescendants().size());
    List<UniqueId> uniqueIds = uniqueIds();
    assertThat(uniqueIds).contains(uniqueIdForClass(Class1WithTestCases.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(Class1WithTestCases.class, "test1()"));
    assertThat(uniqueIds).contains(uniqueIdForClass(Class2WithTestCases.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(Class2WithTestCases.class, "test2()"));
    assertThat(uniqueIds).contains(uniqueIdForMethod(ClassWithStaticInnerTestCases.ShouldBeDiscovered.class, "test1()"));
}
Also used : DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) Class2WithTestCases(org.junit.jupiter.engine.descriptor.subpackage.Class2WithTestCases) PackageSelector(org.junit.platform.engine.discovery.PackageSelector) Class1WithTestCases(org.junit.jupiter.engine.descriptor.subpackage.Class1WithTestCases) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Aggregations

Test (org.junit.jupiter.api.Test)2 PackageSelector (org.junit.platform.engine.discovery.PackageSelector)2 DynamicTest (org.junit.jupiter.api.DynamicTest)1 Class1WithTestCases (org.junit.jupiter.engine.descriptor.subpackage.Class1WithTestCases)1 Class2WithTestCases (org.junit.jupiter.engine.descriptor.subpackage.Class2WithTestCases)1 UniqueId (org.junit.platform.engine.UniqueId)1 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)1 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)1