Search in sources :

Example 1 with TestIdentifier

use of org.junit.platform.launcher.TestIdentifier in project intellij-community by JetBrains.

the class JUnit5TestExecutionListener method sendTree.

public void sendTree(TestPlan testPlan, String rootName) {
    myTestPlan = testPlan;
    myRootName = rootName;
    myRoots = testPlan.getRoots();
    for (TestIdentifier root : myRoots) {
        assert root.isContainer();
        for (TestIdentifier testIdentifier : testPlan.getChildren(root)) {
            sendTreeUnderRoot(testPlan, testIdentifier, new HashSet<>());
        }
    }
    myPrintStream.println("##teamcity[treeEnded]");
}
Also used : TestIdentifier(org.junit.platform.launcher.TestIdentifier)

Example 2 with TestIdentifier

use of org.junit.platform.launcher.TestIdentifier in project intellij-community by JetBrains.

the class JUnit5NavigationTest method locationHint.

private String locationHint() {
    descriptor.use(myTestSource);
    TestIdentifier testIdentifier = TestIdentifier.from(descriptor);
    return JUnit5TestExecutionListener.getLocationHint(testIdentifier);
}
Also used : TestIdentifier(org.junit.platform.launcher.TestIdentifier)

Example 3 with TestIdentifier

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

the class JUnitPlatformTestExecutionListener method createDescriptor.

private TestDescriptorInternal createDescriptor(TestIdentifier test, String name, String displayName) {
    TestIdentifier classIdentifier = findClassSource(test);
    String className = className(classIdentifier);
    String classDisplayName = classDisplayName(classIdentifier);
    return new DefaultTestDescriptor(idGenerator.generateId(), className, name, classDisplayName, displayName);
}
Also used : TestIdentifier(org.junit.platform.launcher.TestIdentifier) DefaultTestDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestDescriptor)

Example 4 with TestIdentifier

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

the class XmlReportWriter method writeTestsuite.

private void writeTestsuite(TestIdentifier testIdentifier, List<TestIdentifier> tests, XMLStreamWriter writer) throws XMLStreamException {
    // NumberFormat is not thread-safe. Thus, we instantiate it here and pass it to
    // writeTestcase instead of using a constant
    NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
    writer.writeStartElement("testsuite");
    writeSuiteAttributes(testIdentifier, tests, numberFormat, writer);
    newLine(writer);
    writeSystemProperties(writer);
    for (TestIdentifier test : tests) {
        writeTestcase(test, numberFormat, writer);
    }
    writeNonStandardAttributesToSystemOutElement(testIdentifier, writer);
    writer.writeEndElement();
    newLine(writer);
}
Also used : TestIdentifier(org.junit.platform.launcher.TestIdentifier) NumberFormat(java.text.NumberFormat)

Example 5 with TestIdentifier

use of org.junit.platform.launcher.TestIdentifier 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();
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) TestEngineSpy(org.junit.platform.engine.test.TestEngineSpy) ConfigurationParameters(org.junit.platform.engine.ConfigurationParameters) TestPlan(org.junit.platform.launcher.TestPlan) EngineFilter.excludeEngines(org.junit.platform.launcher.EngineFilter.excludeEngines) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) FilterResult(org.junit.platform.engine.FilterResult) TestEngine(org.junit.platform.engine.TestEngine) TestDescriptorStub(org.junit.platform.engine.test.TestDescriptorStub) TestExecutionResult.successful(org.junit.platform.engine.TestExecutionResult.successful) EngineExecutionListener(org.junit.platform.engine.EngineExecutionListener) ArgumentCaptor(org.mockito.ArgumentCaptor) LauncherFactoryForTestingPurposesOnly.createLauncher(org.junit.platform.launcher.core.LauncherFactoryForTestingPurposesOnly.createLauncher) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) LauncherDiscoveryRequestBuilder.request(org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.request) EngineFilter.includeEngines(org.junit.platform.launcher.EngineFilter.includeEngines) CollectionUtils.getOnlyElement(org.junit.platform.commons.util.CollectionUtils.getOnlyElement) InOrder(org.mockito.InOrder) PostDiscoveryFilter(org.junit.platform.launcher.PostDiscoveryFilter) JUnitException(org.junit.platform.commons.JUnitException) TestEngineStub(org.junit.platform.engine.test.TestEngineStub) UniqueId(org.junit.platform.engine.UniqueId) Test(org.junit.jupiter.api.Test) PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) TestIdentifier(org.junit.platform.launcher.TestIdentifier) PostDiscoveryFilterStub(org.junit.platform.launcher.PostDiscoveryFilterStub) SummaryGeneratingListener(org.junit.platform.launcher.listeners.SummaryGeneratingListener) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) DemoHierarchicalTestDescriptor(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor) Mockito.inOrder(org.mockito.Mockito.inOrder) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) ExecutionRequest(org.junit.platform.engine.ExecutionRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) DiscoverySelectors.selectPackage(org.junit.platform.engine.discovery.DiscoverySelectors.selectPackage) ArgumentMatchers.same(org.mockito.ArgumentMatchers.same) Mockito.mock(org.mockito.Mockito.mock) TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) TestPlan(org.junit.platform.launcher.TestPlan) TestIdentifier(org.junit.platform.launcher.TestIdentifier) TestDescriptorStub(org.junit.platform.engine.test.TestDescriptorStub) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) TestEngineSpy(org.junit.platform.engine.test.TestEngineSpy) Test(org.junit.jupiter.api.Test)

Aggregations

TestIdentifier (org.junit.platform.launcher.TestIdentifier)54 Test (org.junit.jupiter.api.Test)33 TestPlan (org.junit.platform.launcher.TestPlan)27 TestExecutionResult (org.junit.platform.engine.TestExecutionResult)15 LauncherDiscoveryRequestBuilder (org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder)11 Categories (org.junit.vintage.engine.samples.junit4.Categories)10 TestDescriptor (org.junit.platform.engine.TestDescriptor)9 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 TestDescriptorStub (org.junit.platform.engine.test.TestDescriptorStub)7 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)6 EnclosedJUnit4TestCase (org.junit.vintage.engine.samples.junit4.EnclosedJUnit4TestCase)6 PlainJUnit4TestCaseWithFiveTestMethods (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods)6 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 CollectionUtils.getOnlyElement (org.junit.platform.commons.util.CollectionUtils.getOnlyElement)4 DiscoverySelectors.selectClass (org.junit.platform.engine.discovery.DiscoverySelectors.selectClass)4