use of org.apache.maven.surefire.util.TestsToRun in project junit5 by junit-team.
the class JUnitPlatformProviderTests method allGivenTestsToRunAreInvoked.
@Test
void allGivenTestsToRunAreInvoked() throws Exception {
Launcher launcher = LauncherFactory.create();
JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParametersMock(), launcher);
TestPlanSummaryListener executionListener = new TestPlanSummaryListener();
launcher.registerTestExecutionListeners(executionListener);
TestsToRun testsToRun = newTestsToRun(TestClass1.class, TestClass2.class);
invokeProvider(provider, testsToRun);
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.util.TestsToRun in project junit5 by junit-team.
the class JUnitPlatformProvider method scanClasspath.
private TestsToRun scanClasspath() {
TestPlanScannerFilter filter = new TestPlanScannerFilter(launcher, filters);
ScanResult scanResult = parameters.getScanResult();
TestsToRun scannedClasses = scanResult.applyFilter(filter, parameters.getTestClassLoader());
return parameters.getRunOrderCalculator().orderTestClasses(scannedClasses);
}
use of org.apache.maven.surefire.util.TestsToRun 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);
}
use of org.apache.maven.surefire.util.TestsToRun in project junit5 by junit-team.
the class JUnitPlatformProviderTests method providerParametersMock.
private static ProviderParameters providerParametersMock(RunListener runListener, TestListResolver testListResolver, Class<?>... testClasses) {
TestsToRun testsToRun = newTestsToRun(testClasses);
ScanResult scanResult = mock(ScanResult.class);
when(scanResult.applyFilter(any(), any())).thenReturn(testsToRun);
RunOrderCalculator runOrderCalculator = mock(RunOrderCalculator.class);
when(runOrderCalculator.orderTestClasses(any())).thenReturn(testsToRun);
ReporterFactory reporterFactory = mock(ReporterFactory.class);
when(reporterFactory.createReporter()).thenReturn(runListener);
TestRequest testRequest = mock(TestRequest.class);
when(testRequest.getTestListResolver()).thenReturn(testListResolver);
ProviderParameters providerParameters = mock(ProviderParameters.class);
when(providerParameters.getScanResult()).thenReturn(scanResult);
when(providerParameters.getRunOrderCalculator()).thenReturn(runOrderCalculator);
when(providerParameters.getReporterFactory()).thenReturn(reporterFactory);
when(providerParameters.getTestRequest()).thenReturn(testRequest);
return providerParameters;
}
Aggregations