use of org.junit.platform.engine.test.TestDescriptorStub in project junit5 by junit-team.
the class TestIdentifierTests method inheritsIdAndNamesFromDescriptor.
@Test
void inheritsIdAndNamesFromDescriptor() {
TestDescriptor testDescriptor = new TestDescriptorStub(UniqueId.root("aType", "uniqueId"), "displayName");
TestIdentifier testIdentifier = TestIdentifier.from(testDescriptor);
assertEquals("[aType:uniqueId]", testIdentifier.getUniqueId());
assertEquals("displayName", testIdentifier.getDisplayName());
}
use of org.junit.platform.engine.test.TestDescriptorStub in project junit5 by junit-team.
the class TestIdentifierTests method inheritsTypeFromDescriptor.
@Test
void inheritsTypeFromDescriptor() {
TestDescriptor descriptor = new TestDescriptorStub(UniqueId.root("aType", "uniqueId"), "displayName");
TestIdentifier identifier = TestIdentifier.from(descriptor);
assertEquals(TestDescriptor.Type.TEST, identifier.getType());
assertTrue(identifier.isTest());
assertFalse(identifier.isContainer());
descriptor.addChild(new TestDescriptorStub(UniqueId.root("aChild", "uniqueId"), "displayName"));
identifier = TestIdentifier.from(descriptor);
assertEquals(TestDescriptor.Type.CONTAINER, identifier.getType());
assertFalse(identifier.isTest());
assertTrue(identifier.isContainer());
}
use of org.junit.platform.engine.test.TestDescriptorStub in project junit5 by junit-team.
the class DefaultLauncherTests method prunesTestDescriptorsAfterApplyingPostDiscoveryFilters.
@Test
void prunesTestDescriptorsAfterApplyingPostDiscoveryFilters() {
TestEngineSpy engine = new TestEngineSpy() {
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
super.discover(discoveryRequest, uniqueId);
TestDescriptorStub engineDescriptor = new TestDescriptorStub(uniqueId, uniqueId.toString());
TestDescriptorStub containerDescriptor = new TestDescriptorStub(uniqueId.append("container", "a"), "container") {
@Override
public Type getType() {
return Type.CONTAINER;
}
};
containerDescriptor.addChild(new TestDescriptorStub(containerDescriptor.getUniqueId().append("test", "b"), "test"));
engineDescriptor.addChild(containerDescriptor);
return engineDescriptor;
}
};
DefaultLauncher launcher = createLauncher(engine);
TestPlan testPlan = launcher.discover(request().filters((PostDiscoveryFilter) testDescriptor -> FilterResult.includedIf(testDescriptor.isContainer())).build());
assertThat(testPlan.getRoots()).hasSize(1);
TestIdentifier engineIdentifier = getOnlyElement(testPlan.getRoots());
assertThat(testPlan.getChildren(engineIdentifier)).isEmpty();
}
use of org.junit.platform.engine.test.TestDescriptorStub in project junit5 by junit-team.
the class XmlReportWriterTests method writesEmptyErrorElementForFailedTestWithoutCause.
@Test
void writesEmptyErrorElementForFailedTestWithoutCause() throws Exception {
engineDescriptor = new EngineDescriptor(UniqueId.forEngine("myEngineId"), "Fancy Engine") {
@Override
public String getLegacyReportingName() {
return "myEngine";
}
};
UniqueId uniqueId = engineDescriptor.getUniqueId().append("test", "test");
engineDescriptor.addChild(new TestDescriptorStub(uniqueId, "some fancy name") {
@Override
public String getLegacyReportingName() {
return "failedTest";
}
});
TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
reportData.markFinished(testPlan.getTestIdentifier(uniqueId.toString()), failed(null));
String content = writeXmlReport(testPlan, reportData);
assertValidAccordingToJenkinsSchema(content);
// @formatter:off
assertThat(content).containsSubsequence("<testcase name=\"failedTest\" classname=\"myEngine\"", "<error/>", "</testcase>");
// @formatter:on
}
use of org.junit.platform.engine.test.TestDescriptorStub in project junit5 by junit-team.
the class XmlReportWriterTests method writesReportEntry.
@Test
void writesReportEntry() throws Exception {
UniqueId uniqueId = engineDescriptor.getUniqueId().append("test", "test");
TestDescriptorStub testDescriptor = new TestDescriptorStub(uniqueId, "successfulTest");
engineDescriptor.addChild(testDescriptor);
TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
reportData.addReportEntry(TestIdentifier.from(testDescriptor), ReportEntry.from("myKey", "myValue"));
reportData.markFinished(testPlan.getTestIdentifier(uniqueId.toString()), successful());
String content = writeXmlReport(testPlan, reportData);
assertValidAccordingToJenkinsSchema(content);
// @formatter:off
assertThat(content).containsSubsequence("<system-out>", "Report Entry #1 (timestamp: ", "- myKey: myValue", "</system-out>");
// @formatter:on
}
Aggregations