use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class DefaultLauncherTests method prunesTestDescriptorsAfterApplyingPostDiscoveryFilters.
@Test
void prunesTestDescriptorsAfterApplyingPostDiscoveryFilters() {
var engine = new TestEngineSpy() {
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
super.discover(discoveryRequest, uniqueId);
var engineDescriptor = new TestDescriptorStub(uniqueId, uniqueId.toString());
var 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;
}
};
var launcher = createLauncher(engine);
var testPlan = launcher.discover(request().filters((PostDiscoveryFilter) testDescriptor -> FilterResult.includedIf(testDescriptor.isContainer())).build());
assertThat(testPlan.getRoots()).hasSize(1);
var engineIdentifier = getOnlyElement(testPlan.getRoots());
assertThat(testPlan.getChildren(engineIdentifier)).isEmpty();
}
use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class XmlReportWriterTests method omitsMessageAttributeForFailedTestWithThrowableWithoutMessage.
@Test
void omitsMessageAttributeForFailedTestWithThrowableWithoutMessage() throws Exception {
var uniqueId = engineDescriptor.getUniqueId().append("test", "test");
engineDescriptor.addChild(new TestDescriptorStub(uniqueId, "failedTest"));
var testPlan = TestPlan.from(Set.of(engineDescriptor), configParams);
var reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
reportData.markFinished(testPlan.getTestIdentifier(uniqueId.toString()), failed(new NullPointerException()));
var testsuite = writeXmlReport(testPlan, reportData);
assertValidAccordingToJenkinsSchema(testsuite.document());
var error = testsuite.find("error");
assertThat(error.attr("type")).isEqualTo("java.lang.NullPointerException");
assertThat(error.attr("message")).isNull();
}
use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class XmlReportDataTests method resultsOfTestIdentifierWithoutAnyReportedEventsAreEmpty.
@Test
void resultsOfTestIdentifierWithoutAnyReportedEventsAreEmpty() {
var engineDescriptor = new EngineDescriptor(UniqueId.forEngine("engine"), "Engine");
engineDescriptor.addChild(new TestDescriptorStub(UniqueId.root("child", "test"), "test"));
var testPlan = TestPlan.from(Set.of(engineDescriptor), configParams);
var reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
var results = reportData.getResults(testPlan.getTestIdentifier("[child:test]"));
assertThat(results).isEmpty();
}
use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class XmlReportDataTests method resultsOfTestIdentifierWithoutReportedEventsContainsOnlySuccessOfAncestor.
@Test
void resultsOfTestIdentifierWithoutReportedEventsContainsOnlySuccessOfAncestor() {
var engineDescriptor = new EngineDescriptor(UniqueId.forEngine("engine"), "Engine");
engineDescriptor.addChild(new TestDescriptorStub(UniqueId.root("child", "test"), "test"));
var testPlan = TestPlan.from(Set.of(engineDescriptor), configParams);
var reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
reportData.markFinished(testPlan.getTestIdentifier("[engine:engine]"), successful());
var results = reportData.getResults(testPlan.getTestIdentifier("[child:test]"));
assertThat(results).containsExactly(successful());
}
use of org.junit.platform.fakes.TestDescriptorStub in project junit5 by junit-team.
the class SummaryGenerationTests method reportingConcurrentlyFinishedTests.
@RepeatedTest(10)
void reportingConcurrentlyFinishedTests() throws Exception {
var numThreads = 250;
var testIdentifier = TestIdentifier.from(new TestDescriptorStub(UniqueId.root("root", "2"), "failingTest") {
@Override
public Optional<TestSource> getSource() {
return Optional.of(ClassSource.from(Object.class));
}
});
var result = TestExecutionResult.failed(new RuntimeException());
listener.testPlanExecutionStarted(testPlan);
executeConcurrently(numThreads, () -> {
listener.executionStarted(testIdentifier);
listener.executionFinished(testIdentifier, result);
});
listener.testPlanExecutionFinished(testPlan);
assertThat(listener.getSummary().getFailures()).hasSize(numThreads);
}
Aggregations