use of org.apache.maven.surefire.util.ScanResult 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.ScanResult 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;
}
use of org.apache.maven.surefire.util.ScanResult in project tycho by eclipse.
the class TestMojoTest method testExcludes.
@Test
public void testExcludes() throws Exception {
List<String> includes = new ArrayList<>();
includes.add("*");
List<String> excludes = new ArrayList<>();
// adding a null to simulate an unresolved parameter interpolation
excludes.add(null);
excludes.add("*Another*");
ScanResult result = createDirectoryAndScanForTests(includes, excludes);
assertEquals(1, result.size());
}
use of org.apache.maven.surefire.util.ScanResult in project tycho by eclipse.
the class TestMojoTest method testIncludes.
@Test
public void testIncludes() throws Exception {
List<String> includes = new ArrayList<>();
includes.add("*Another*");
includes.add(null);
ScanResult result = createDirectoryAndScanForTests(includes, null);
assertEquals(1, result.size());
}
use of org.apache.maven.surefire.util.ScanResult in project tycho by eclipse.
the class TestMojo method createSurefireProperties.
private void createSurefireProperties(TestFrameworkProvider provider) throws MojoExecutionException {
PropertiesWrapper wrapper = new PropertiesWrapper(new HashMap<String, String>());
wrapper.setProperty("testpluginname", getTestBundleSymbolicName());
wrapper.setProperty("testclassesdirectory", testClassesDirectory.getAbsolutePath());
wrapper.setProperty("reportsdirectory", reportsDirectory.getAbsolutePath());
wrapper.setProperty("redirectTestOutputToFile", String.valueOf(redirectTestOutputToFile));
wrapper.setProperty("failifnotests", String.valueOf(failIfNoTests));
wrapper.setProperty("runOrder", runOrder);
wrapper.setProperty("skipAfterFailureCount", String.valueOf(skipAfterFailureCount));
wrapper.setProperty("rerunFailingTestsCount", String.valueOf(rerunFailingTestsCount));
Properties mergedProviderProperties = getMergedProviderProperties();
mergedProviderProperties.putAll(provider.getProviderSpecificProperties());
ScanResult scanResult = scanForTests();
Map<String, String> providerPropertiesAsMap = propertiesAsMap(mergedProviderProperties);
scanResult.writeTo(providerPropertiesAsMap);
for (Map.Entry<String, String> entry : providerPropertiesAsMap.entrySet()) {
wrapper.setProperty("__provider." + entry.getKey(), entry.getValue().toString());
}
wrapper.setProperty("testprovider", provider.getSurefireProviderClassName());
getLog().debug("Using test framework provider " + provider.getClass().getName());
wrapper.addList(suiteXmlFiles, BooterConstants.TEST_SUITE_XML_FILES);
storeProperties(wrapper.getProperties(), surefireProperties);
}
Aggregations