use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method removesWholeSubtree.
@Test
void removesWholeSubtree() {
Class<?> testClass = EnclosedJUnit4TestCase.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)).containsExactlyInAnyOrder("JUnit Vintage");
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesAllTestsForNotFilterableChildRunnerOfSuite.
@TrackLogRecords
@Test
void executesAllTestsForNotFilterableChildRunnerOfSuite(LogRecordListener logRecordListener) {
Class<?> suiteClass = JUnit4SuiteOfSuiteWithFilterableChildRunner.class;
Class<?> testClass = JUnit4TestCaseWithNotFilterableRunner.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(suiteClass)).filters((PostDiscoveryFilter) descriptor -> includedIf(descriptor.getDisplayName().contains("#1")));
TestPlan testPlan = discover(request);
logRecordListener.clear();
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(4);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", suiteClass.getName(), testClass.getName(), "Test #0", "Test #1");
//
assertThat(logRecordListener.stream(RunnerTestDescriptor.class, Level.WARNING).map(LogRecord::getMessage)).containsExactly(//
"Runner " + Suite.class.getName() + " (used on class " + suiteClass.getName() + ")" + " was not able to satisfy all filter requests.");
}
use of org.junit.platform.engine.TestExecutionResult 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.TestExecutionResult in project junit5 by junit-team.
the class RunListenerAdapter method handleFailure.
private void handleFailure(Failure failure, Function<Throwable, TestExecutionResult> resultCreator, TestDescriptor testDescriptor) {
TestExecutionResult result = resultCreator.apply(failure.getException());
testRun.storeResult(testDescriptor, result);
if (testDescriptor.isContainer() && testRun.isDescendantOfRunnerTestDescriptor(testDescriptor)) {
fireMissingContainerEvents(testDescriptor);
}
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class TestRun method getStoredResultOrSuccessful.
TestExecutionResult getStoredResultOrSuccessful(TestDescriptor testDescriptor) {
List<TestExecutionResult> testExecutionResults = executionResults.get(testDescriptor);
if (testExecutionResults == null) {
return successful();
}
if (testExecutionResults.size() == 1) {
return testExecutionResults.get(0);
}
// @formatter:off
List<Throwable> failures = testExecutionResults.stream().map(TestExecutionResult::getThrowable).map(Optional::get).collect(toList());
// @formatter:on
return failed(new MultipleFailuresError("", failures));
}
Aggregations