Search in sources :

Example 31 with TestPlan

use of org.junit.platform.launcher.TestPlan 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 32 with TestPlan

use of org.junit.platform.launcher.TestPlan 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 33 with TestPlan

use of org.junit.platform.launcher.TestPlan 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 34 with TestPlan

use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.

the class XmlReportWriterTests method writesTestsuiteElementsWithoutTestcaseElementsWithoutAnyTests.

@Test
void writesTestsuiteElementsWithoutTestcaseElementsWithoutAnyTests() throws Exception {
    TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
    XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
    String content = writeXmlReport(testPlan, reportData);
    assertValidAccordingToJenkinsSchema(content);
    // @formatter:off
    assertThat(content).containsSubsequence("<testsuite name=\"Engine\" tests=\"0\"", "</testsuite>").doesNotContain("<testcase");
// @formatter:on
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) Test(org.junit.jupiter.api.Test)

Example 35 with TestPlan

use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.

the class XmlReportWriterTests method writesEmptySkippedElementForSkippedTestWithoutReason.

@Test
void writesEmptySkippedElementForSkippedTestWithoutReason() throws Exception {
    UniqueId uniqueId = engineDescriptor.getUniqueId().append("test", "test");
    engineDescriptor.addChild(new TestDescriptorStub(uniqueId, "skippedTest"));
    TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
    XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
    reportData.markSkipped(testPlan.getTestIdentifier(uniqueId.toString()), null);
    String content = writeXmlReport(testPlan, reportData);
    assertValidAccordingToJenkinsSchema(content);
    // @formatter:off
    assertThat(content).containsSubsequence("<testcase name=\"skippedTest\"", "<skipped/>", "</testcase>");
// @formatter:on
}
Also used : UniqueId(org.junit.platform.engine.UniqueId) TestPlan(org.junit.platform.launcher.TestPlan) TestDescriptorStub(org.junit.platform.engine.test.TestDescriptorStub) Test(org.junit.jupiter.api.Test)

Aggregations

TestPlan (org.junit.platform.launcher.TestPlan)47 Test (org.junit.jupiter.api.Test)38 TestIdentifier (org.junit.platform.launcher.TestIdentifier)24 TestExecutionResult (org.junit.platform.engine.TestExecutionResult)16 EngineDescriptor (org.junit.platform.engine.support.descriptor.EngineDescriptor)16 LauncherDiscoveryRequestBuilder (org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder)11 SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)10 Categories (org.junit.vintage.engine.samples.junit4.Categories)10 TestDescriptorStub (org.junit.platform.engine.test.TestDescriptorStub)9 UniqueId (org.junit.platform.engine.UniqueId)8 Launcher (org.junit.platform.launcher.Launcher)8 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)8 ReportEntry (org.apache.maven.surefire.report.ReportEntry)7 TestDescriptor (org.junit.platform.engine.TestDescriptor)6 EnclosedJUnit4TestCase (org.junit.vintage.engine.samples.junit4.EnclosedJUnit4TestCase)6 PlainJUnit4TestCaseWithFiveTestMethods (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods)6 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)4 TestEngine (org.junit.platform.engine.TestEngine)4 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)4