use of org.apache.maven.surefire.report.ReporterFactory 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.report.ReporterFactory in project junit5 by junit-team.
the class JUnitPlatformProvider method invokeAllTests.
private RunResult invokeAllTests(TestsToRun testsToRun) {
RunResult runResult;
ReporterFactory reporterFactory = parameters.getReporterFactory();
try {
RunListener runListener = reporterFactory.createReporter();
ConsoleOutputCapture.startCapture((ConsoleOutputReceiver) runListener);
LauncherDiscoveryRequest discoveryRequest = buildLauncherDiscoveryRequest(testsToRun);
launcher.execute(discoveryRequest, new RunListenerAdapter(runListener));
} finally {
runResult = reporterFactory.close();
}
return runResult;
}
use of org.apache.maven.surefire.report.ReporterFactory in project tycho by eclipse.
the class OsgiSurefireBooter method run.
public static int run(String[] args) throws Exception {
Properties testProps = loadProperties(getTestProperties(args));
boolean failIfNoTests = Boolean.parseBoolean(testProps.getProperty("failifnotests", "false"));
boolean redirectTestOutputToFile = Boolean.parseBoolean(testProps.getProperty("redirectTestOutputToFile", "false"));
String testPlugin = testProps.getProperty("testpluginname");
File testClassesDir = new File(testProps.getProperty("testclassesdirectory"));
File reportsDir = new File(testProps.getProperty("reportsdirectory"));
String provider = testProps.getProperty("testprovider");
String runOrder = testProps.getProperty("runOrder");
int skipAfterFailureCount = Integer.parseInt(testProps.getProperty("skipAfterFailureCount", "0"));
int rerunFailingTestsCount = Integer.parseInt(testProps.getProperty("rerunFailingTestsCount", "0"));
Map<String, String> propertiesMap = new HashMap<String, String>();
for (String key : testProps.stringPropertyNames()) {
propertiesMap.put(key, testProps.getProperty(key));
}
PropertiesWrapper wrapper = new PropertiesWrapper(propertiesMap);
List<String> suiteXmlFiles = wrapper.getStringList(BooterConstants.TEST_SUITE_XML_FILES);
boolean forkRequested = true;
boolean inForkedVM = true;
boolean trimStacktrace = true;
boolean useSystemClassloader = false;
boolean useManifestOnlyJar = false;
boolean useFile = true;
boolean printSummary = true;
boolean disableXmlReport = false;
ClasspathConfiguration classPathConfig = new ClasspathConfiguration(false, false);
StartupConfiguration startupConfiguration = new StartupConfiguration(provider, classPathConfig, new ClassLoaderConfiguration(useSystemClassloader, useManifestOnlyJar), forkRequested, inForkedVM);
// TODO dir scanning with no includes done here (done in TestMojo already)
// but without dirScannerParams we get an NPE accessing runOrder
DirectoryScannerParameters dirScannerParams = new DirectoryScannerParameters(testClassesDir, Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList(), failIfNoTests, runOrder);
ReporterConfiguration reporterConfig = new ReporterConfiguration(reportsDir, trimStacktrace);
TestRequest testRequest = new TestRequest(suiteXmlFiles, testClassesDir, TestListResolver.getEmptyTestListResolver());
ProviderConfiguration providerConfiguration = new ProviderConfiguration(dirScannerParams, new RunOrderParameters(runOrder, null), failIfNoTests, reporterConfig, null, testRequest, extractProviderProperties(testProps), null, false, Collections.<CommandLineOption>emptyList(), skipAfterFailureCount, Shutdown.DEFAULT);
StartupReportConfiguration startupReportConfig = new StartupReportConfiguration(useFile, printSummary, StartupReportConfiguration.PLAIN_REPORT_FORMAT, redirectTestOutputToFile, disableXmlReport, reportsDir, trimStacktrace, null, "TESTHASH", false, rerunFailingTestsCount);
ReporterFactory reporterFactory = new DefaultReporterFactory(startupReportConfig);
// API indicates we should use testClassLoader below but surefire also tries
// to load surefire classes using this classloader
RunResult result = ProviderFactory.invokeProvider(null, createCombinedClassLoader(testPlugin), reporterFactory, providerConfiguration, false, startupConfiguration, true);
// counter-intuitive, but null indicates OK here
return result.getFailsafeCode() == null ? 0 : result.getFailsafeCode();
}
Aggregations