use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method resolvesJUnit3TestCase.
@Test
void resolvesJUnit3TestCase() throws Exception {
Class<?> testClass = PlainJUnit3TestCaseWithSingleTestWhichFails.class;
LauncherDiscoveryRequest discoveryRequest = discoveryRequestForClass(testClass);
TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
assertRunnerTestDescriptor(runnerDescriptor, testClass);
TestDescriptor childDescriptor = getOnlyElement(runnerDescriptor.getChildren());
assertTestMethodDescriptor(childDescriptor, testClass, "test", VintageUniqueIdBuilder.uniqueIdForClass(testClass));
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method resolvesCategoriesIntoTags.
@Test
void resolvesCategoriesIntoTags() {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
LauncherDiscoveryRequest discoveryRequest = discoveryRequestForClass(testClass);
TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
assertThat(runnerDescriptor.getTags()).containsOnly(TestTag.create(Plain.class.getName()));
TestDescriptor failingTest = findChildByDisplayName(runnerDescriptor, "failingTest");
//
assertThat(failingTest.getTags()).containsOnly(//
TestTag.create(Plain.class.getName()), TestTag.create(Failing.class.getName()));
TestDescriptor ignoredWithoutReason = findChildByDisplayName(runnerDescriptor, "ignoredTest1_withoutReason");
//
assertThat(ignoredWithoutReason.getTags()).containsOnly(//
TestTag.create(Plain.class.getName()), TestTag.create(Skipped.class.getName()));
TestDescriptor ignoredWithReason = findChildByDisplayName(runnerDescriptor, "ignoredTest2_withReason");
//
assertThat(ignoredWithReason.getTags()).containsOnly(//
TestTag.create(Plain.class.getName()), //
TestTag.create(Skipped.class.getName()), TestTag.create(SkippedWithReason.class.getName()));
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class VintageTestEngineExecutionTests method reportsExecutionEventsAroundLifecycleMethods.
@Test
void reportsExecutionEventsAroundLifecycleMethods() {
Class<?> testClass = PlainJUnit4TestCaseWithLifecycleMethods.class;
PlainJUnit4TestCaseWithLifecycleMethods.EVENTS.clear();
EngineExecutionListener listener = new EngineExecutionListener() {
@Override
public void executionStarted(TestDescriptor testDescriptor) {
PlainJUnit4TestCaseWithLifecycleMethods.EVENTS.add("executionStarted:" + testDescriptor.getDisplayName());
}
@Override
public void executionFinished(TestDescriptor testDescriptor, TestExecutionResult testExecutionResult) {
PlainJUnit4TestCaseWithLifecycleMethods.EVENTS.add("executionFinished:" + testDescriptor.getDisplayName());
}
@Override
public void executionSkipped(TestDescriptor testDescriptor, String reason) {
PlainJUnit4TestCaseWithLifecycleMethods.EVENTS.add("executionSkipped:" + testDescriptor.getDisplayName());
}
@Override
public void dynamicTestRegistered(TestDescriptor testDescriptor) {
}
@Override
public void reportingEntryPublished(TestDescriptor testDescriptor, ReportEntry entry) {
}
};
execute(testClass, listener);
// @formatter:off
assertThat(PlainJUnit4TestCaseWithLifecycleMethods.EVENTS).containsExactly("executionStarted:JUnit Vintage", "executionStarted:" + testClass.getName(), "beforeClass", "executionStarted:failingTest", "before", "failingTest", "after", "executionFinished:failingTest", "executionSkipped:skippedTest", "executionStarted:succeedingTest", "before", "succeedingTest", "after", "executionFinished:succeedingTest", "afterClass", "executionFinished:" + testClass.getName(), "executionFinished:JUnit Vintage");
// @formatter:on
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class VintageDiscovererTests method packageNameFilterExcludesClasses.
@Test
void packageNameFilterExcludesClasses() {
// @formatter:off
EngineDiscoveryRequest request = request().selectors(selectClass(Foo.class), selectClass(Bar.class)).filters(PackageNameFilter.excludePackageNames("org.junit.vintage.engine.discovery")).build();
// @formatter:on
VintageDiscoverer discoverer = new VintageDiscoverer();
TestDescriptor testDescriptor = discoverer.discover(request, engineId());
assertThat(testDescriptor.getChildren()).isEmpty();
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class VintageDiscovererTests method doesNotResolve.
private void doesNotResolve(LogRecordListener listener, Class<?> testClass) {
LauncherDiscoveryRequest request = request().selectors(selectClass(testClass)).build();
VintageDiscoverer discoverer = new VintageDiscoverer();
TestDescriptor testDescriptor = discoverer.discover(request, engineId());
assertThat(testDescriptor.getChildren()).isEmpty();
assertThat(listener.stream(VintageDiscoverer.class)).isEmpty();
}
Aggregations