Search in sources :

Example 6 with ReportEntry

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

the class JUnitPlatformProviderTests method usesClassNamesForXmlReport.

@Test
void usesClassNamesForXmlReport() throws TestSetFailedException, InvocationTargetException {
    String[] classNames = { "org.junit.platform.surefire.provider.JUnitPlatformProviderTests$Sub1Tests", "org.junit.platform.surefire.provider.JUnitPlatformProviderTests$Sub2Tests" };
    ProviderParameters providerParameters = providerParametersMock(Sub1Tests.class, Sub2Tests.class);
    JUnitPlatformProvider jUnitPlatformProvider = new JUnitPlatformProvider(providerParameters);
    TestsToRun testsToRun = newTestsToRun(Sub1Tests.class, Sub2Tests.class);
    invokeProvider(jUnitPlatformProvider, testsToRun);
    RunListener reporter = providerParameters.getReporterFactory().createReporter();
    ArgumentCaptor<ReportEntry> reportEntryArgumentCaptor = ArgumentCaptor.forClass(ReportEntry.class);
    verify(reporter, times(2)).testSucceeded(reportEntryArgumentCaptor.capture());
    List<ReportEntry> allValues = reportEntryArgumentCaptor.getAllValues();
    assertThat(allValues).extracting(ReportEntry::getSourceName).containsExactly(classNames);
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) ReportEntry(org.apache.maven.surefire.report.ReportEntry) TestsToRun(org.apache.maven.surefire.util.TestsToRun) RunListener(org.apache.maven.surefire.report.RunListener) Test(org.junit.jupiter.api.Test)

Example 7 with ReportEntry

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

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

the class RunListenerAdapterTests method displayNamesIgnoredInReport.

@Test
void displayNamesIgnoredInReport() throws NoSuchMethodException {
    TestMethodTestDescriptor descriptor = new TestMethodTestDescriptor(newId(), MyTestClass.class, MyTestClass.class.getDeclaredMethod("myNamedTestMethod"));
    TestIdentifier factoryIdentifier = TestIdentifier.from(descriptor);
    ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
    adapter.executionSkipped(factoryIdentifier, "");
    verify(listener).testSkipped(entryCaptor.capture());
    ReportEntry value = entryCaptor.getValue();
    assertEquals("myNamedTestMethod", value.getName());
}
Also used : ReportEntry(org.apache.maven.surefire.report.ReportEntry) SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) TestIdentifier(org.junit.platform.launcher.TestIdentifier) TestMethodTestDescriptor(org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor) Test(org.junit.jupiter.api.Test)

Example 9 with ReportEntry

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

Aggregations

ReportEntry (org.apache.maven.surefire.report.ReportEntry)9 SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)9 Test (org.junit.jupiter.api.Test)9 EngineDescriptor (org.junit.platform.engine.support.descriptor.EngineDescriptor)7 TestIdentifier (org.junit.platform.launcher.TestIdentifier)7 TestPlan (org.junit.platform.launcher.TestPlan)7 ProviderParameters (org.apache.maven.surefire.providerapi.ProviderParameters)1 RunListener (org.apache.maven.surefire.report.RunListener)1 TestsToRun (org.apache.maven.surefire.util.TestsToRun)1 TestMethodTestDescriptor (org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor)1