use of org.junit.platform.engine.UniqueId 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
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class XmlReportWriterTests method omitsMessageAttributeForFailedTestWithThrowableWithoutMessage.
@Test
void omitsMessageAttributeForFailedTestWithThrowableWithoutMessage() throws Exception {
UniqueId uniqueId = engineDescriptor.getUniqueId().append("test", "test");
engineDescriptor.addChild(new TestDescriptorStub(uniqueId, "failedTest"));
TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
reportData.markFinished(testPlan.getTestIdentifier(uniqueId.toString()), failed(new NullPointerException()));
String content = writeXmlReport(testPlan, reportData);
assertValidAccordingToJenkinsSchema(content);
// @formatter:off
assertThat(content).containsSubsequence("<testcase name=\"failedTest\"", "<error type=\"java.lang.NullPointerException\">", "</testcase>");
// @formatter:on
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class RunListenerAdapter method registerDynamicTestDescriptor.
private VintageTestDescriptor registerDynamicTestDescriptor(Description description) {
// workaround for dynamic children as used by Spock's Runner
TestDescriptor parent = findParent(description);
UniqueId uniqueId = parent.getUniqueId().append(SEGMENT_TYPE_DYNAMIC, uniqueIdExtractor.apply(description));
VintageTestDescriptor dynamicDescriptor = new VintageTestDescriptor(uniqueId, description);
parent.addChild(dynamicDescriptor);
testRun.registerDynamicTest(dynamicDescriptor);
dynamicTestRegistered(dynamicDescriptor);
return dynamicDescriptor;
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingDynamicTestByUniqueIdAndTestFactoryByMethodSelectorResolvesTestFactory.
@Test
void resolvingDynamicTestByUniqueIdAndTestFactoryByMethodSelectorResolvesTestFactory() {
Class<?> clazz = MyTestClass.class;
UniqueId factoryUid = uniqueIdForTestFactoryMethod(clazz, "dynamicTest()");
UniqueId dynamicTestUid = factoryUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#1");
LauncherDiscoveryRequest request = //
request().selectors(selectUniqueId(dynamicTestUid), //
selectMethod(clazz, "dynamicTest")).build();
resolver.resolveSelectors(request, engineDescriptor);
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), factoryUid);
TestDescriptor testClassDescriptor = getOnlyElement(engineDescriptor.getChildren());
TestDescriptor testFactoryDescriptor = getOnlyElement(testClassDescriptor.getChildren());
DynamicDescendantFilter dynamicDescendantFilter = getDynamicDescendantFilter(testFactoryDescriptor);
assertThat(dynamicDescendantFilter.test(UniqueId.root("foo", "bar"))).isTrue();
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method testFactoryMethodResolutionByUniqueId.
@Test
void testFactoryMethodResolutionByUniqueId() {
Class<?> clazz = MyTestClass.class;
UniqueId factoryUid = uniqueIdForTestFactoryMethod(clazz, "dynamicTest()");
resolver.resolveSelectors(request().selectors(selectUniqueId(factoryUid)).build(), engineDescriptor);
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), factoryUid);
}
Aggregations