use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.
the class JupiterIntegrationTests method resolve.
@Test
void resolve() {
assumeTrue(getClass().getModule().isNamed(), "not running on the module-path");
ModuleSelector selector = DiscoverySelectors.selectModule(getClass().getModule().getName());
assertEquals(getClass().getModule().getName(), selector.getModuleName());
EngineDescriptor engine = new JupiterEngineDescriptor(UniqueId.forEngine(JupiterTestEngine.ENGINE_ID));
DiscoverySelectorResolver resolver = new DiscoverySelectorResolver();
resolver.resolveSelectors(request().selectors(selector).build(), engine);
// JupiterIntegrationTests.class
assertEquals(1, engine.getChildren().size());
// 5 test methods
assertEquals(5, getOnlyElement(engine.getChildren()).getChildren().size());
}
use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.
the class XmlReportDataTests method resultOfTestIdentifierWithoutReportedEventsIsEmptyWhenAncestorWasSuccessful.
@Test
void resultOfTestIdentifierWithoutReportedEventsIsEmptyWhenAncestorWasSuccessful() {
EngineDescriptor engineDescriptor = new EngineDescriptor(UniqueId.forEngine("engine"), "Engine");
engineDescriptor.addChild(new TestDescriptorStub(UniqueId.root("child", "test"), "test"));
TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
reportData.markFinished(testPlan.getTestIdentifier("[engine:engine]"), successful());
Optional<TestExecutionResult> result = reportData.getResult(testPlan.getTestIdentifier("[child:test]"));
assertThat(result).isEmpty();
}
use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.
the class XmlReportDataTests method resultOfTestIdentifierWithoutAnyReportedEventsIsEmpty.
@Test
void resultOfTestIdentifierWithoutAnyReportedEventsIsEmpty() {
EngineDescriptor engineDescriptor = new EngineDescriptor(UniqueId.forEngine("engine"), "Engine");
engineDescriptor.addChild(new TestDescriptorStub(UniqueId.root("child", "test"), "test"));
TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
Optional<TestExecutionResult> result = reportData.getResult(testPlan.getTestIdentifier("[child:test]"));
assertThat(result).isEmpty();
}
use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.
the class XmlReportDataTests method resultOfTestIdentifierWithoutReportedEventsIsFailureOfAncestor.
@Test
void resultOfTestIdentifierWithoutReportedEventsIsFailureOfAncestor() {
EngineDescriptor engineDescriptor = new EngineDescriptor(UniqueId.forEngine("engine"), "Engine");
engineDescriptor.addChild(new TestDescriptorStub(UniqueId.root("child", "test"), "test"));
TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
TestExecutionResult failureOfAncestor = failed(new RuntimeException("failed!"));
reportData.markFinished(testPlan.getTestIdentifier("[engine:engine]"), failureOfAncestor);
Optional<TestExecutionResult> result = reportData.getResult(testPlan.getTestIdentifier("[child:test]"));
assertThat(result).contains(failureOfAncestor);
}
use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method printsExceptionWhenReportCouldNotBeWritten.
@Test
void printsExceptionWhenReportCouldNotBeWritten(@Root Path tempDirectory) throws Exception {
EngineDescriptor engineDescriptor = new EngineDescriptor(UniqueId.forEngine("engine"), "Engine");
Path xmlFile = tempDirectory.resolve("TEST-engine.xml");
Files.createDirectories(xmlFile);
StringWriter out = new StringWriter();
XmlReportsWritingListener listener = new XmlReportsWritingListener(tempDirectory, new PrintWriter(out));
listener.testPlanExecutionStarted(TestPlan.from(singleton(engineDescriptor)));
listener.executionFinished(TestIdentifier.from(engineDescriptor), successful());
assertThat(out.toString()).containsSubsequence("Could not write XML report", "Exception", "at ");
}
Aggregations