Search in sources :

Example 1 with SimpleReportEntry

use of org.apache.maven.surefire.report.SimpleReportEntry in project junit5 by junit-team.

the class RunListenerAdapterTests method notifiedForTestSetForSingleNodeEngine.

@Test
void notifiedForTestSetForSingleNodeEngine() {
    EngineDescriptor engine = new EngineDescriptor(UniqueId.forEngine("engine"), "engine") {

        @Override
        public Type getType() {
            return Type.TEST;
        }
    };
    TestPlan plan = TestPlan.from(Collections.singletonList(engine));
    adapter.testPlanExecutionStarted(plan);
    adapter.executionStarted(TestIdentifier.from(engine));
    InOrder inOrder = inOrder(listener);
    inOrder.verify(listener).testSetStarting(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "engine"));
    inOrder.verify(listener).testStarting(new SimpleReportEntry("<unrooted>", "engine"));
    inOrder.verifyNoMoreInteractions();
    adapter.executionFinished(TestIdentifier.from(engine), successful());
    inOrder = inOrder(listener);
    inOrder.verify(listener).testSucceeded(new SimpleReportEntry("<unrooted>", "engine"));
    inOrder.verify(listener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "engine"));
    inOrder.verifyNoMoreInteractions();
}
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) Test(org.junit.jupiter.api.Test)

Example 2 with SimpleReportEntry

use of org.apache.maven.surefire.report.SimpleReportEntry 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 3 with SimpleReportEntry

use of org.apache.maven.surefire.report.SimpleReportEntry in project junit5 by junit-team.

the class JUnitPlatformProviderTests method allDiscoveredTestsAreInvokedForNullArgument.

@Test
void allDiscoveredTestsAreInvokedForNullArgument() throws Exception {
    RunListener runListener = runListenerMock();
    ProviderParameters providerParameters = providerParametersMock(runListener, TestClass1.class, TestClass2.class);
    Launcher launcher = LauncherFactory.create();
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters, launcher);
    TestPlanSummaryListener executionListener = new TestPlanSummaryListener();
    launcher.registerTestExecutionListeners(executionListener);
    invokeProvider(provider, null);
    InOrder inOrder = inOrder(runListener);
    inOrder.verify(runListener).testSetStarting(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), TestClass1.class.getName()));
    inOrder.verify(runListener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), TestClass1.class.getName()));
    inOrder.verify(runListener).testSetStarting(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), TestClass2.class.getName()));
    inOrder.verify(runListener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), TestClass2.class.getName()));
    assertThat(executionListener.summaries).hasSize(1);
    TestExecutionSummary summary = executionListener.summaries.get(0);
    assertEquals(TestClass1.TESTS_FOUND + TestClass2.TESTS_FOUND, summary.getTestsFoundCount());
    assertEquals(TestClass1.TESTS_STARTED + TestClass2.TESTS_STARTED, summary.getTestsStartedCount());
    assertEquals(TestClass1.TESTS_SKIPPED + TestClass2.TESTS_SKIPPED, summary.getTestsSkippedCount());
    assertEquals(TestClass1.TESTS_SUCCEEDED + TestClass2.TESTS_SUCCEEDED, summary.getTestsSucceededCount());
    assertEquals(TestClass1.TESTS_ABORTED + TestClass2.TESTS_ABORTED, summary.getTestsAbortedCount());
    assertEquals(TestClass1.TESTS_FAILED + TestClass2.TESTS_FAILED, summary.getTestsFailedCount());
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) InOrder(org.mockito.InOrder) TestExecutionSummary(org.junit.platform.launcher.listeners.TestExecutionSummary) Launcher(org.junit.platform.launcher.Launcher) RunListener(org.apache.maven.surefire.report.RunListener) Test(org.junit.jupiter.api.Test)

Example 4 with SimpleReportEntry

use of org.apache.maven.surefire.report.SimpleReportEntry 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 5 with SimpleReportEntry

use of org.apache.maven.surefire.report.SimpleReportEntry 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

SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)6 Test (org.junit.jupiter.api.Test)5 EngineDescriptor (org.junit.platform.engine.support.descriptor.EngineDescriptor)4 ClassTestDescriptor (org.junit.jupiter.engine.descriptor.ClassTestDescriptor)3 TestMethodTestDescriptor (org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor)3 TestDescriptor (org.junit.platform.engine.TestDescriptor)3 AbstractTestDescriptor (org.junit.platform.engine.support.descriptor.AbstractTestDescriptor)3 TestPlan (org.junit.platform.launcher.TestPlan)3 InOrder (org.mockito.InOrder)3 RunListener (org.apache.maven.surefire.report.RunListener)2 JUnit4StackTraceWriter (org.apache.maven.surefire.common.junit4.JUnit4StackTraceWriter)1 ProviderParameters (org.apache.maven.surefire.providerapi.ProviderParameters)1 TestSetFailedException (org.apache.maven.surefire.testset.TestSetFailedException)1 Launcher (org.junit.platform.launcher.Launcher)1 TestExecutionSummary (org.junit.platform.launcher.listeners.TestExecutionSummary)1