use of org.apache.maven.plugin.surefire.report.DefaultReporterFactory 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