use of org.junit.platform.engine.UniqueId 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.UniqueId in project junit5 by junit-team.
the class DemoHierarchicalTestEngine method addContainer.
public DemoHierarchicalContainerDescriptor addContainer(String uniqueName, String displayName, TestSource source, Runnable beforeBlock) {
UniqueId uniqueId = engineDescriptor.getUniqueId().append("container", uniqueName);
DemoHierarchicalContainerDescriptor container = new DemoHierarchicalContainerDescriptor(uniqueId, displayName, source, beforeBlock);
engineDescriptor.addChild(container);
return container;
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class DemoHierarchicalTestEngine method addTest.
public DemoHierarchicalTestDescriptor addTest(String uniqueName, String displayName, Runnable executeBlock) {
UniqueId uniqueId = engineDescriptor.getUniqueId().append("test", uniqueName);
DemoHierarchicalTestDescriptor child = new DemoHierarchicalTestDescriptor(uniqueId, displayName, executeBlock);
engineDescriptor.addChild(child);
return child;
}
use of org.junit.platform.engine.UniqueId 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.UniqueId 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