Search in sources :

Example 11 with EngineDescriptor

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());
}
Also used : ModuleSelector(org.junit.platform.engine.discovery.ModuleSelector) DiscoverySelectorResolver(org.junit.jupiter.engine.discovery.DiscoverySelectorResolver) EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor) JupiterEngineDescriptor(org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor) JupiterEngineDescriptor(org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor) Test(org.junit.jupiter.api.Test)

Example 12 with EngineDescriptor

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();
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor) TestDescriptorStub(org.junit.platform.engine.test.TestDescriptorStub) TestExecutionResult(org.junit.platform.engine.TestExecutionResult) Test(org.junit.jupiter.api.Test)

Example 13 with EngineDescriptor

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();
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor) TestDescriptorStub(org.junit.platform.engine.test.TestDescriptorStub) TestExecutionResult(org.junit.platform.engine.TestExecutionResult) Test(org.junit.jupiter.api.Test)

Example 14 with EngineDescriptor

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);
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor) TestDescriptorStub(org.junit.platform.engine.test.TestDescriptorStub) TestExecutionResult(org.junit.platform.engine.TestExecutionResult) Test(org.junit.jupiter.api.Test)

Example 15 with EngineDescriptor

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 ");
}
Also used : Path(java.nio.file.Path) StringWriter(java.io.StringWriter) EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor) PrintWriter(java.io.PrintWriter) Test(org.junit.jupiter.api.Test)

Aggregations

EngineDescriptor (org.junit.platform.engine.support.descriptor.EngineDescriptor)19 Test (org.junit.jupiter.api.Test)18 TestPlan (org.junit.platform.launcher.TestPlan)15 SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)11 ReportEntry (org.apache.maven.surefire.report.ReportEntry)7 TestIdentifier (org.junit.platform.launcher.TestIdentifier)7 TestDescriptorStub (org.junit.platform.engine.test.TestDescriptorStub)5 ClassTestDescriptor (org.junit.jupiter.engine.descriptor.ClassTestDescriptor)3 TestMethodTestDescriptor (org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor)3 TestDescriptor (org.junit.platform.engine.TestDescriptor)3 TestExecutionResult (org.junit.platform.engine.TestExecutionResult)3 AbstractTestDescriptor (org.junit.platform.engine.support.descriptor.AbstractTestDescriptor)3 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 InOrder (org.mockito.InOrder)2 Path (java.nio.file.Path)1 LinkedHashMap (java.util.LinkedHashMap)1 JupiterEngineDescriptor (org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor)1 DiscoverySelectorResolver (org.junit.jupiter.engine.discovery.DiscoverySelectorResolver)1 UniqueId (org.junit.platform.engine.UniqueId)1