Search in sources :

Example 6 with EngineDescriptor

use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.

the class RunListenerAdapterTests method notifiedWithCorrectNamesWhenClassExecutionSkipped.

@Test
void notifiedWithCorrectNamesWhenClassExecutionSkipped() throws Exception {
    ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
    TestPlan testPlan = TestPlan.from(Collections.singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
    adapter.testPlanExecutionStarted(testPlan);
    TestIdentifier classIdentifier = identifiersAsParentOnTestPlan(testPlan, newEngineDescriptor(), newClassDescriptor());
    adapter.executionSkipped(classIdentifier, "test");
    verify(listener).testSkipped(entryCaptor.capture());
    ReportEntry entry = entryCaptor.getValue();
    assertTrue(MyTestClass.class.getTypeName().contains(entry.getName()));
    assertEquals(MyTestClass.class.getTypeName(), entry.getSourceName());
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) ReportEntry(org.apache.maven.surefire.report.ReportEntry) SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor) TestIdentifier(org.junit.platform.launcher.TestIdentifier) Test(org.junit.jupiter.api.Test)

Example 7 with EngineDescriptor

use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.

the class RunListenerAdapterTests method notifiedEagerlyForTestSetWhenClassExecutionStarted.

@Test
void notifiedEagerlyForTestSetWhenClassExecutionStarted() throws Exception {
    EngineDescriptor engine = newEngineDescriptor();
    TestDescriptor parent = newClassDescriptor();
    engine.addChild(parent);
    TestDescriptor child = newMethodDescriptor();
    parent.addChild(child);
    TestPlan plan = TestPlan.from(Collections.singletonList(engine));
    adapter.testPlanExecutionStarted(plan);
    adapter.executionStarted(TestIdentifier.from(engine));
    adapter.executionStarted(TestIdentifier.from(parent));
    verify(listener).testSetStarting(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), MyTestClass.class.getName()));
    verifyNoMoreInteractions(listener);
    adapter.executionStarted(TestIdentifier.from(child));
    verify(listener).testStarting(new SimpleReportEntry(MyTestClass.class.getName(), MY_TEST_METHOD_NAME));
    verifyNoMoreInteractions(listener);
    adapter.executionFinished(TestIdentifier.from(child), successful());
    verify(listener).testSucceeded(new SimpleReportEntry(MyTestClass.class.getName(), MY_TEST_METHOD_NAME));
    verifyNoMoreInteractions(listener);
    adapter.executionFinished(TestIdentifier.from(parent), successful());
    verify(listener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), MyTestClass.class.getName()));
    verifyNoMoreInteractions(listener);
    adapter.executionFinished(TestIdentifier.from(engine), successful());
    verifyNoMoreInteractions(listener);
}
Also used : SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) TestPlan(org.junit.platform.launcher.TestPlan) EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor) ClassTestDescriptor(org.junit.jupiter.engine.descriptor.ClassTestDescriptor) TestMethodTestDescriptor(org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor) AbstractTestDescriptor(org.junit.platform.engine.support.descriptor.AbstractTestDescriptor) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 8 with EngineDescriptor

use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.

the class RunListenerAdapterTests method stackTraceWriterDefaultsToTestClass.

@Test
void stackTraceWriterDefaultsToTestClass() throws Exception {
    TestPlan plan = TestPlan.from(Collections.singletonList(new EngineDescriptor(newId(), "Some Plan")));
    adapter.testPlanExecutionStarted(plan);
    TestIdentifier child = newSourcelessChildIdentifierWithParent(plan, "Parent", null);
    adapter.executionFinished(child, TestExecutionResult.failed(new RuntimeException("message")));
    ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
    verify(listener).testError(entryCaptor.capture());
    assertNotNull(entryCaptor.getValue().getStackTraceWriter());
    assertNotNull(entryCaptor.getValue().getStackTraceWriter().smartTrimmedStackTrace());
    assertNotNull(entryCaptor.getValue().getStackTraceWriter().writeTraceToString());
    assertNotNull(entryCaptor.getValue().getStackTraceWriter().writeTrimmedTraceToString());
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) ReportEntry(org.apache.maven.surefire.report.ReportEntry) SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor) TestIdentifier(org.junit.platform.launcher.TestIdentifier) Test(org.junit.jupiter.api.Test)

Example 9 with EngineDescriptor

use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.

the class RunListenerAdapterTests method stackTraceWriterPresentWhenParentHasSource.

@Test
void stackTraceWriterPresentWhenParentHasSource() throws Exception {
    TestPlan plan = TestPlan.from(Collections.singletonList(new EngineDescriptor(newId(), "Some Plan")));
    adapter.testPlanExecutionStarted(plan);
    TestIdentifier child = newSourcelessChildIdentifierWithParent(plan, "Parent", ClassSource.from(MyTestClass.class));
    adapter.executionFinished(child, TestExecutionResult.failed(new RuntimeException()));
    ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
    verify(listener).testError(entryCaptor.capture());
    assertNotNull(entryCaptor.getValue().getStackTraceWriter());
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) ReportEntry(org.apache.maven.surefire.report.ReportEntry) SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor) TestIdentifier(org.junit.platform.launcher.TestIdentifier) Test(org.junit.jupiter.api.Test)

Example 10 with EngineDescriptor

use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.

the class VintageDiscoverer method discover.

public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
    EngineDescriptor engineDescriptor = new EngineDescriptor(uniqueId, "JUnit Vintage");
    // @formatter:off
    collectTestClasses(discoveryRequest).toRequests().map(request -> resolver.createRunnerTestDescriptor(request, uniqueId)).filter(Objects::nonNull).forEach(engineDescriptor::addChild);
    // @formatter:on
    return engineDescriptor;
}
Also used : EngineDescriptor(org.junit.platform.engine.support.descriptor.EngineDescriptor)

Aggregations

EngineDescriptor (org.junit.platform.engine.support.descriptor.EngineDescriptor)19 Test (org.junit.jupiter.api.Test)18 TestPlan (org.junit.platform.launcher.TestPlan)15 SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)11 ReportEntry (org.apache.maven.surefire.report.ReportEntry)7 TestIdentifier (org.junit.platform.launcher.TestIdentifier)7 TestDescriptorStub (org.junit.platform.engine.test.TestDescriptorStub)5 ClassTestDescriptor (org.junit.jupiter.engine.descriptor.ClassTestDescriptor)3 TestMethodTestDescriptor (org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor)3 TestDescriptor (org.junit.platform.engine.TestDescriptor)3 TestExecutionResult (org.junit.platform.engine.TestExecutionResult)3 AbstractTestDescriptor (org.junit.platform.engine.support.descriptor.AbstractTestDescriptor)3 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 InOrder (org.mockito.InOrder)2 Path (java.nio.file.Path)1 LinkedHashMap (java.util.LinkedHashMap)1 JupiterEngineDescriptor (org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor)1 DiscoverySelectorResolver (org.junit.jupiter.engine.discovery.DiscoverySelectorResolver)1 UniqueId (org.junit.platform.engine.UniqueId)1