use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.
the class XmlReportData method getResult.
Optional<TestExecutionResult> getResult(TestIdentifier testIdentifier) {
if (this.finishedTests.containsKey(testIdentifier)) {
return Optional.of(this.finishedTests.get(testIdentifier));
}
Optional<TestIdentifier> parent = this.testPlan.getParent(testIdentifier);
Optional<TestIdentifier> ancestor = findAncestor(parent, this.finishedTests::containsKey);
if (ancestor.isPresent()) {
TestExecutionResult result = this.finishedTests.get(ancestor.get());
if (result.getStatus() != SUCCESSFUL) {
return Optional.of(result);
}
}
return Optional.empty();
}
use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method removesCompleteClassIfItHasExcludedTag.
@Test
void removesCompleteClassIfItHasExcludedTag() {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(excludeTags(Categories.Plain.class.getName()));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).isEmpty();
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactly("JUnit Vintage");
}
use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesOnlyNotExcludedTaggedMethodOfNestedTestClass.
@Test
void executesOnlyNotExcludedTaggedMethodOfNestedTestClass() {
Class<?> testClass = EnclosedJUnit4TestCase.class;
Class<?> nestedTestClass = EnclosedJUnit4TestCase.NestedClass.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(excludeTags(Categories.Failing.class.getName()));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(3);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", testClass.getName(), nestedTestClass.getName(), "successfulTest");
}
use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method removesCompleteClassIfNoMethodHasMatchingTags.
@Test
void removesCompleteClassIfNoMethodHasMatchingTags() {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(includeTags("wrong-tag"));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).isEmpty();
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactly("JUnit Vintage");
}
use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesAllTestsForNotFilterableRunner.
@TrackLogRecords
@Test
void executesAllTestsForNotFilterableRunner(LogRecordListener logRecordListener) {
Class<?> testClass = JUnit4TestCaseWithNotFilterableRunner.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters((PostDiscoveryFilter) descriptor -> includedIf(descriptor.getDisplayName().contains("#1")));
TestPlan testPlan = discover(request);
logRecordListener.clear();
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(3);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", testClass.getName(), "Test #0", "Test #1");
//
assertThat(logRecordListener.stream(RunnerTestDescriptor.class, Level.WARNING).map(LogRecord::getMessage)).containsExactly(//
"Runner " + NotFilterableRunner.class.getName() + " (used on class " + testClass.getName() + ")" + " does not support filtering and will therefore be run completely.");
}
Aggregations