use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class XmlReportWriterTests method omitsMessageAttributeForFailedTestWithThrowableWithoutMessage.
@Test
void omitsMessageAttributeForFailedTestWithThrowableWithoutMessage() throws Exception {
UniqueId uniqueId = engineDescriptor.getUniqueId().append("test", "test");
engineDescriptor.addChild(new TestDescriptorStub(uniqueId, "failedTest"));
TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
reportData.markFinished(testPlan.getTestIdentifier(uniqueId.toString()), failed(new NullPointerException()));
String content = writeXmlReport(testPlan, reportData);
assertValidAccordingToJenkinsSchema(content);
// @formatter:off
assertThat(content).containsSubsequence("<testcase name=\"failedTest\"", "<error type=\"java.lang.NullPointerException\">", "</testcase>");
// @formatter:on
}
use of org.junit.platform.launcher.TestPlan 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.TestPlan 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.TestPlan 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.");
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class DefaultLauncherTests method discoverTestPlanForEngineThatThrowsAnErrorInDiscoverPhase.
@Test
void discoverTestPlanForEngineThatThrowsAnErrorInDiscoverPhase() {
TestEngine engine = new TestEngineStub() {
@Override
public TestDescriptor discover(org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
throw new Error("ignored");
}
};
TestPlan testPlan = createLauncher(engine).discover(request().build());
assertThat(testPlan.getRoots()).hasSize(0);
}
Aggregations