Search in sources :

Example 11 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters in project junit5 by junit-team.

the class JUnitPlatformProviderTests method testExecutionOfMatchingTestMethods.

void testExecutionOfMatchingTestMethods(Class<?> testClass, String pattern, String... expectedTestNames) throws Exception {
    TestListResolver testListResolver = new TestListResolver(pattern);
    ProviderParameters providerParameters = providerParametersMock(testListResolver, testClass);
    Launcher launcher = LauncherFactory.create();
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters, launcher);
    TestPlanSummaryListener executionListener = new TestPlanSummaryListener();
    launcher.registerTestExecutionListeners(executionListener);
    invokeProvider(provider, null);
    assertEquals(1, executionListener.summaries.size());
    TestExecutionSummary summary = executionListener.summaries.get(0);
    int expectedCount = expectedTestNames.length;
    assertEquals(expectedCount, summary.getTestsFoundCount());
    assertEquals(expectedCount, summary.getTestsFailedCount());
    assertEquals(expectedCount, summary.getFailures().size());
    assertThat(failedTestDisplayNames(summary)).contains(expectedTestNames);
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) TestExecutionSummary(org.junit.platform.launcher.listeners.TestExecutionSummary) Launcher(org.junit.platform.launcher.Launcher) TestListResolver(org.apache.maven.surefire.testset.TestListResolver)

Example 12 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters 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 13 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters in project junit5 by junit-team.

the class JUnitPlatformProviderTests method bothIncludeAndExcludeAreAllowed.

@Test
void bothIncludeAndExcludeAreAllowed() throws Exception {
    Map<String, String> properties = new HashMap<>();
    properties.put(JUnitPlatformProvider.INCLUDE_TAGS, "tagOne, tagTwo");
    properties.put(JUnitPlatformProvider.EXCLUDE_TAGS, "tagThree, tagFour");
    ProviderParameters providerParameters = providerParametersMock(TestClass1.class);
    when(providerParameters.getProviderProperties()).thenReturn(properties);
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters);
    assertEquals(2, provider.filters.length);
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 14 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters in project junit5 by junit-team.

the class JUnitPlatformProviderTests method defaultConfigurationParametersAreEmpty.

@Test
void defaultConfigurationParametersAreEmpty() {
    ProviderParameters providerParameters = providerParametersMock(TestClass1.class);
    when(providerParameters.getProviderProperties()).thenReturn(emptyMap());
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters);
    assertTrue(provider.configurationParameters.isEmpty());
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) Test(org.junit.jupiter.api.Test)

Example 15 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters in project junit5 by junit-team.

the class JUnitPlatformProviderTests method getSuitesReturnsScannedClasses.

@Test
void getSuitesReturnsScannedClasses() throws Exception {
    ProviderParameters providerParameters = providerParametersMock(TestClass1.class, TestClass2.class);
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters);
    assertThat(provider.getSuites()).containsOnly(TestClass1.class, TestClass2.class);
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) Test(org.junit.jupiter.api.Test)

Aggregations

ProviderParameters (org.apache.maven.surefire.providerapi.ProviderParameters)15 Test (org.junit.jupiter.api.Test)12 HashMap (java.util.HashMap)5 RunListener (org.apache.maven.surefire.report.RunListener)2 SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)2 TestsToRun (org.apache.maven.surefire.util.TestsToRun)2 Launcher (org.junit.platform.launcher.Launcher)2 TestExecutionSummary (org.junit.platform.launcher.listeners.TestExecutionSummary)2 ReportEntry (org.apache.maven.surefire.report.ReportEntry)1 ReporterFactory (org.apache.maven.surefire.report.ReporterFactory)1 TestListResolver (org.apache.maven.surefire.testset.TestListResolver)1 TestRequest (org.apache.maven.surefire.testset.TestRequest)1 RunOrderCalculator (org.apache.maven.surefire.util.RunOrderCalculator)1 ScanResult (org.apache.maven.surefire.util.ScanResult)1 InOrder (org.mockito.InOrder)1