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);
}
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());
}
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);
}
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());
}
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);
}
Aggregations