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 TestRunTests method returnsEmptyOptionalForUnknownDescriptions.
@Test
void returnsEmptyOptionalForUnknownDescriptions() throws Exception {
Class<?> testClass = PlainJUnit4TestCaseWithSingleTestWhichFails.class;
UniqueId runnerId = engineId().append(SEGMENT_TYPE_RUNNER, testClass.getName());
RunnerTestDescriptor runnerTestDescriptor = new RunnerTestDescriptor(runnerId, testClass, new BlockJUnit4ClassRunner(testClass));
Description unknownDescription = createTestDescription(testClass, "dynamicTest");
TestRun testRun = new TestRun(runnerTestDescriptor);
Optional<VintageTestDescriptor> testDescriptor = testRun.lookupTestDescriptor(unknownDescription);
assertThat(testDescriptor).isEmpty();
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestTemplateTestDescriptorTests method inheritsTagsFromParent.
@Test
void inheritsTagsFromParent() throws Exception {
UniqueId rootUniqueId = UniqueId.root("segment", "template");
UniqueId parentUniqueId = rootUniqueId.append("class", "myClass");
AbstractTestDescriptor parent = containerTestDescriptorWithTags(parentUniqueId, singleton(TestTag.create("foo")));
TestTemplateTestDescriptor testDescriptor = new TestTemplateTestDescriptor(parentUniqueId.append("tmp", "testTemplate()"), MyTestCase.class, MyTestCase.class.getDeclaredMethod("testTemplate"));
parent.addChild(testDescriptor);
assertThat(testDescriptor.getTags()).containsExactlyInAnyOrder(TestTag.create("foo"), TestTag.create("bar"), TestTag.create("baz"));
}
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();
}
Aggregations