Search in sources :

Example 16 with EngineDescriptor

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

the class RunListenerAdapterTests method notifiedWithCorrectNamesWhenMethodExecutionStarted.

@Test
void notifiedWithCorrectNamesWhenMethodExecutionStarted() 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 methodIdentifier = identifiersAsParentOnTestPlan(testPlan, newClassDescriptor(), newMethodDescriptor());
    adapter.executionStarted(methodIdentifier);
    verify(listener).testStarting(entryCaptor.capture());
    ReportEntry entry = entryCaptor.getValue();
    assertEquals(MY_TEST_METHOD_NAME, entry.getName());
    assertEquals(MyTestClass.class.getName(), entry.getSourceName());
    assertNull(entry.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 17 with EngineDescriptor

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

the class RunListenerAdapterTests method notifiedLazilyForTestSetWhenFirstTestWithoutClassDescriptorParentStarted.

@Test
void notifiedLazilyForTestSetWhenFirstTestWithoutClassDescriptorParentStarted() {
    EngineDescriptor engine = newEngineDescriptor();
    TestDescriptor parent = newTestDescriptor(engine.getUniqueId().append("container", "noClass"), "parent", Type.CONTAINER);
    engine.addChild(parent);
    TestDescriptor child1 = newTestDescriptor(parent.getUniqueId().append("test", "child1"), "child1", Type.TEST);
    parent.addChild(child1);
    TestDescriptor child2 = newTestDescriptor(parent.getUniqueId().append("test", "child2"), "child2", Type.TEST);
    parent.addChild(child2);
    TestPlan plan = TestPlan.from(Collections.singletonList(engine));
    adapter.testPlanExecutionStarted(plan);
    adapter.executionStarted(TestIdentifier.from(engine));
    adapter.executionStarted(TestIdentifier.from(parent));
    verifyZeroInteractions(listener);
    adapter.executionStarted(TestIdentifier.from(child1));
    InOrder inOrder = inOrder(listener);
    inOrder.verify(listener).testSetStarting(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "parent"));
    inOrder.verify(listener).testStarting(new SimpleReportEntry("parent", "child1"));
    inOrder.verifyNoMoreInteractions();
    adapter.executionFinished(TestIdentifier.from(child1), successful());
    verify(listener).testSucceeded(new SimpleReportEntry("parent", "child1"));
    verifyNoMoreInteractions(listener);
    adapter.executionStarted(TestIdentifier.from(child2));
    verify(listener).testStarting(new SimpleReportEntry("parent", "child2"));
    verifyNoMoreInteractions(listener);
    adapter.executionFinished(TestIdentifier.from(child2), successful());
    verify(listener).testSucceeded(new SimpleReportEntry("parent", "child2"));
    verifyNoMoreInteractions(listener);
    adapter.executionFinished(TestIdentifier.from(parent), successful());
    verify(listener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "parent"));
    verifyNoMoreInteractions(listener);
    adapter.executionFinished(TestIdentifier.from(engine), successful());
    verifyNoMoreInteractions(listener);
}
Also used : SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) InOrder(org.mockito.InOrder) 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 18 with EngineDescriptor

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

the class RunListenerAdapterTests method notifiedWithCompatibleNameForMethodWithArguments.

@Test
void notifiedWithCompatibleNameForMethodWithArguments() 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 methodIdentifier = identifiersAsParentOnTestPlan(testPlan, newClassDescriptor(), newMethodDescriptor(String.class));
    adapter.executionStarted(methodIdentifier);
    verify(listener).testStarting(entryCaptor.capture());
    ReportEntry entry = entryCaptor.getValue();
    assertEquals(MY_TEST_METHOD_NAME + "{String}", entry.getName());
    assertEquals(MyTestClass.class.getName(), entry.getSourceName());
    assertNull(entry.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 19 with EngineDescriptor

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

the class RunListenerAdapterTests method notifiedForTestSetWhenClassExecutionSucceeded.

@Test
void notifiedForTestSetWhenClassExecutionSucceeded() throws Exception {
    EngineDescriptor engineDescriptor = newEngineDescriptor();
    TestDescriptor classDescriptor = newClassDescriptor();
    engineDescriptor.addChild(classDescriptor);
    adapter.testPlanExecutionStarted(TestPlan.from(singleton(engineDescriptor)));
    adapter.executionStarted(TestIdentifier.from(classDescriptor));
    adapter.executionFinished(TestIdentifier.from(classDescriptor), successful());
    verify(listener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), MyTestClass.class.getName()));
    verify(listener, never()).testSucceeded(any());
}
Also used : SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) 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)

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