Search in sources :

Example 46 with TestIdentifier

use of org.junit.platform.launcher.TestIdentifier in project gradle by gradle.

the class JUnitPlatformTestExecutionListener method getAncestors.

private Set<TestIdentifier> getAncestors(TestIdentifier testIdentifier) {
    Set<TestIdentifier> result = new LinkedHashSet<>();
    Optional<String> parentId = testIdentifier.getParentId();
    while (parentId.isPresent()) {
        TestIdentifier parent = currentTestPlan.getTestIdentifier(parentId.get());
        result.add(parent);
        parentId = parent.getParentId();
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TestIdentifier(org.junit.platform.launcher.TestIdentifier)

Example 47 with TestIdentifier

use of org.junit.platform.launcher.TestIdentifier in project gradle by gradle.

the class JUnitPlatformTestExecutionListener method createTestClassDescriptor.

private DefaultTestClassDescriptor createTestClassDescriptor(TestIdentifier node) {
    TestIdentifier classIdentifier = findTestClassIdentifier(node);
    String className = className(classIdentifier);
    String classDisplayName = node.getDisplayName();
    return new DefaultTestClassDescriptor(idGenerator.generateId(), className, classDisplayName);
}
Also used : DefaultTestClassDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor) TestIdentifier(org.junit.platform.launcher.TestIdentifier)

Example 48 with TestIdentifier

use of org.junit.platform.launcher.TestIdentifier in project neo4j by neo4j.

the class ProfilerExtensionTest method profilingExtensionMustNotBreakOnUninitialisedTestDirectory.

@Test
void profilingExtensionMustNotBreakOnUninitialisedTestDirectory() {
    // Because this test *aborts* rather than fails or completes normally, we will be in a state where we both have an
    // execution exception *and* the TestDirectoryExtension cleans up after itself as if the test was a success.
    // In this case, the profiler extension will see an uninitialised TestDirectoryExtension, and must be able to cope
    // with that. Furthermore, these particular tests are arranged such that the TestDirectoryExtension has its
    // lifecycle nested within the ProfilerExtension, which means that the test directory will do its cleanup
    // before the profiler extension gets to write its results.
    CONTEXT.clear();
    execute(ProfiledTemplateVerification.class, "testThatFailsBeforeInitialisingTestDirectory", new TestExecutionListener() {

        @Override
        public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
            // Notably, we should not see any FAILED results.
            assertThat(testExecutionResult.getStatus()).isIn(SUCCESSFUL, ABORTED);
        }
    });
}
Also used : TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) TestIdentifier(org.junit.platform.launcher.TestIdentifier) TestExecutionResult(org.junit.platform.engine.TestExecutionResult) Test(org.junit.jupiter.api.Test)

Example 49 with TestIdentifier

use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.

the class XmlReportWriter method writeXmlReport.

void writeXmlReport(TestIdentifier rootDescriptor, Writer out) throws XMLStreamException {
    TestPlan testPlan = this.reportData.getTestPlan();
    Map<TestIdentifier, AggregatedTestResult> tests = // 
    testPlan.getDescendants(rootDescriptor).stream().filter(// 
    testIdentifier -> shouldInclude(testPlan, testIdentifier)).collect(// 
    toMap(identity(), this::toAggregatedResult));
    writeXmlReport(rootDescriptor, tests, out);
}
Also used : StringUtils.isNotBlank(org.junit.platform.commons.util.StringUtils.isNotBlank) Comparator.naturalOrder(java.util.Comparator.naturalOrder) ReportEntry(org.junit.platform.engine.reporting.ReportEntry) TestPlan(org.junit.platform.launcher.TestPlan) Collectors.counting(java.util.stream.Collectors.counting) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) LocalDateTime(java.time.LocalDateTime) ExceptionUtils.readStackTrace(org.junit.platform.commons.util.ExceptionUtils.readStackTrace) TestExecutionResult(org.junit.platform.engine.TestExecutionResult) FAILED(org.junit.platform.engine.TestExecutionResult.Status.FAILED) NumberFormat(java.text.NumberFormat) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress) LinkedHashMap(java.util.LinkedHashMap) ISO_LOCAL_DATE_TIME(java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME) MessageFormat.format(java.text.MessageFormat.format) Collectors.toMap(java.util.stream.Collectors.toMap) Locale(java.util.Locale) Collectors.mapping(java.util.stream.Collectors.mapping) Map(java.util.Map) XMLStreamException(javax.xml.stream.XMLStreamException) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) ERROR(org.junit.platform.reporting.legacy.xml.XmlReportWriter.AggregatedTestResult.Type.ERROR) EnumSet(java.util.EnumSet) Properties(java.util.Properties) Collections.emptyList(java.util.Collections.emptyList) STDOUT_REPORT_ENTRY_KEY(org.junit.platform.launcher.LauncherConstants.STDOUT_REPORT_ENTRY_KEY) Collection(java.util.Collection) FAILURE(org.junit.platform.reporting.legacy.xml.XmlReportWriter.AggregatedTestResult.Type.FAILURE) STDERR_REPORT_ENTRY_KEY(org.junit.platform.launcher.LauncherConstants.STDERR_REPORT_ENTRY_KEY) UnknownHostException(java.net.UnknownHostException) LegacyReportingUtils(org.junit.platform.reporting.legacy.LegacyReportingUtils) XMLOutputFactory(javax.xml.stream.XMLOutputFactory) TestIdentifier(org.junit.platform.launcher.TestIdentifier) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Function.identity(java.util.function.Function.identity) SUCCESS(org.junit.platform.reporting.legacy.xml.XmlReportWriter.AggregatedTestResult.Type.SUCCESS) Writer(java.io.Writer) Entry(java.util.Map.Entry) Optional(java.util.Optional) SKIPPED(org.junit.platform.reporting.legacy.xml.XmlReportWriter.AggregatedTestResult.Type.SKIPPED) Pattern(java.util.regex.Pattern) Type(org.junit.platform.reporting.legacy.xml.XmlReportWriter.AggregatedTestResult.Type) TestPlan(org.junit.platform.launcher.TestPlan) TestIdentifier(org.junit.platform.launcher.TestIdentifier)

Example 50 with TestIdentifier

use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.

the class ExecutionListenerAdapter method dynamicTestRegistered.

@Override
public void dynamicTestRegistered(TestDescriptor testDescriptor) {
    TestIdentifier testIdentifier = TestIdentifier.from(testDescriptor);
    this.testPlan.addInternal(testIdentifier);
    this.testExecutionListener.dynamicTestRegistered(testIdentifier);
}
Also used : TestIdentifier(org.junit.platform.launcher.TestIdentifier)

Aggregations

TestIdentifier (org.junit.platform.launcher.TestIdentifier)53 Test (org.junit.jupiter.api.Test)29 TestPlan (org.junit.platform.launcher.TestPlan)23 TestExecutionResult (org.junit.platform.engine.TestExecutionResult)17 LauncherDiscoveryRequestBuilder (org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder)11 Categories (org.junit.vintage.engine.samples.junit4.Categories)10 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)8 ReportEntry (org.apache.maven.surefire.report.ReportEntry)7 SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)7 EngineDescriptor (org.junit.platform.engine.support.descriptor.EngineDescriptor)7 LinkedHashMap (java.util.LinkedHashMap)6 EnclosedJUnit4TestCase (org.junit.vintage.engine.samples.junit4.EnclosedJUnit4TestCase)6 PlainJUnit4TestCaseWithFiveTestMethods (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods)6 Map (java.util.Map)5 TestDescriptor (org.junit.platform.engine.TestDescriptor)5 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)5 NumberFormat (java.text.NumberFormat)3 ArrayList (java.util.ArrayList)3 MethodTestDescriptor (org.junit.jupiter.engine.descriptor.MethodTestDescriptor)3 Launcher (org.junit.platform.launcher.Launcher)3