Search in sources :

Example 1 with ClassSelector

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

the class DiscoveryRequestCreatorTests method convertsClassSelectors.

@Test
void convertsClassSelectors() {
    options.setSelectedClasses(asList("com.acme.Foo", "com.example.Bar"));
    LauncherDiscoveryRequest request = convert();
    List<ClassSelector> classSelectors = request.getSelectorsByType(ClassSelector.class);
    assertThat(classSelectors).extracting(ClassSelector::getClassName).containsExactly("com.acme.Foo", "com.example.Bar");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ClassSelector(org.junit.platform.engine.discovery.ClassSelector) Test(org.junit.jupiter.api.Test)

Example 2 with ClassSelector

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

the class TestClassWithTemplate method singleClassResolution.

@Test
void singleClassResolution() {
    ClassSelector selector = selectClass(MyTestClass.class);
    resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
    assertEquals(4, engineDescriptor.getDescendants().size());
    List<UniqueId> uniqueIds = uniqueIds();
    assertThat(uniqueIds).contains(uniqueIdForClass(MyTestClass.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test1()"));
    assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test2()"));
    assertThat(uniqueIds).contains(uniqueIdForTestFactoryMethod(MyTestClass.class, "dynamicTest()"));
}
Also used : DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) ClassSelector(org.junit.platform.engine.discovery.ClassSelector) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 3 with ClassSelector

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

the class TestClassWithTemplate method twoClassesResolution.

@Test
void twoClassesResolution() {
    ClassSelector selector1 = selectClass(MyTestClass.class);
    ClassSelector selector2 = selectClass(YourTestClass.class);
    resolver.resolveSelectors(request().selectors(selector1, selector2).build(), engineDescriptor);
    assertEquals(7, engineDescriptor.getDescendants().size());
    List<UniqueId> uniqueIds = uniqueIds();
    assertThat(uniqueIds).contains(uniqueIdForClass(MyTestClass.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test1()"));
    assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test2()"));
    assertThat(uniqueIds).contains(uniqueIdForTestFactoryMethod(MyTestClass.class, "dynamicTest()"));
    assertThat(uniqueIds).contains(uniqueIdForClass(YourTestClass.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(YourTestClass.class, "test3()"));
    assertThat(uniqueIds).contains(uniqueIdForMethod(YourTestClass.class, "test4()"));
}
Also used : DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) ClassSelector(org.junit.platform.engine.discovery.ClassSelector) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 4 with ClassSelector

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

the class TestClassWithTemplate method classResolutionOfStaticNestedClass.

@Test
void classResolutionOfStaticNestedClass() {
    ClassSelector selector = selectClass(OtherTestClass.NestedTestClass.class);
    resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
    assertEquals(3, engineDescriptor.getDescendants().size());
    List<UniqueId> uniqueIds = uniqueIds();
    assertThat(uniqueIds).contains(uniqueIdForClass(OtherTestClass.NestedTestClass.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test5()"));
    assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test6()"));
}
Also used : DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) ClassSelector(org.junit.platform.engine.discovery.ClassSelector) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 5 with ClassSelector

use of org.junit.platform.engine.discovery.ClassSelector in project narchy by automenta.

the class NARTestBenchmark method junit.

// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @Fork(1)
// public void testY() {
// The.Compound.the = FastCompound.FAST_COMPOUND_BUILDER;
// //        Param.SynchronousExecution_Max_CycleTime = 0.0001f;
// 
// junit(testclass);
// }
static void junit(Class... testClasses) {
    LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(// selectPackage("com.example.mytests"),
    (ClassSelector[]) Util.map(DiscoverySelectors::selectClass, new ClassSelector[testClasses.length], testClasses)).build();
    Launcher launcher = LauncherFactory.create();
    // SummaryGeneratingListener listener = new SummaryGeneratingListener();
    LoggingListener listener = LoggingListener.forJavaUtilLogging();
    launcher.registerTestExecutionListeners(listener);
    launcher.execute(request, listener);
// listener.getSummary().printTo(new PrintWriter(System.out));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ClassSelector(org.junit.platform.engine.discovery.ClassSelector) Launcher(org.junit.platform.launcher.Launcher) LoggingListener(org.junit.platform.launcher.listeners.LoggingListener)

Aggregations

ClassSelector (org.junit.platform.engine.discovery.ClassSelector)8 Test (org.junit.jupiter.api.Test)7 DynamicTest (org.junit.jupiter.api.DynamicTest)6 UniqueId (org.junit.platform.engine.UniqueId)6 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)6 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)2 Launcher (org.junit.platform.launcher.Launcher)1 LoggingListener (org.junit.platform.launcher.listeners.LoggingListener)1