Search in sources :

Example 1 with ScanResult

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);
}
Also used : ScanResult(org.apache.maven.surefire.util.ScanResult) TestsToRun(org.apache.maven.surefire.util.TestsToRun)

Example 2 with ScanResult

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;
}
Also used : RunOrderCalculator(org.apache.maven.surefire.util.RunOrderCalculator) ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) ScanResult(org.apache.maven.surefire.util.ScanResult) ReporterFactory(org.apache.maven.surefire.report.ReporterFactory) TestsToRun(org.apache.maven.surefire.util.TestsToRun) TestRequest(org.apache.maven.surefire.testset.TestRequest)

Example 3 with ScanResult

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());
}
Also used : ScanResult(org.apache.maven.surefire.util.ScanResult) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 4 with ScanResult

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());
}
Also used : ScanResult(org.apache.maven.surefire.util.ScanResult) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 5 with ScanResult

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);
}
Also used : ScanResult(org.apache.maven.surefire.util.ScanResult) DefaultScanResult(org.apache.maven.surefire.util.DefaultScanResult) PropertiesWrapper(org.apache.maven.surefire.booter.PropertiesWrapper) Properties(java.util.Properties) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ScanResult (org.apache.maven.surefire.util.ScanResult)5 ArrayList (java.util.ArrayList)2 TestsToRun (org.apache.maven.surefire.util.TestsToRun)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 PropertiesWrapper (org.apache.maven.surefire.booter.PropertiesWrapper)1 ProviderParameters (org.apache.maven.surefire.providerapi.ProviderParameters)1 ReporterFactory (org.apache.maven.surefire.report.ReporterFactory)1 TestRequest (org.apache.maven.surefire.testset.TestRequest)1 DefaultScanResult (org.apache.maven.surefire.util.DefaultScanResult)1 RunOrderCalculator (org.apache.maven.surefire.util.RunOrderCalculator)1