in maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java [1280:1346]
private RunResult executeProvider(
@Nonnull ProviderInfo provider,
@Nonnull DefaultScanResult scanResult,
@Nonnull TestClassPath testClasspathWrapper,
@Nonnull Platform platform,
@Nonnull ResolvePathResultWrapper resolvedJavaModularityResult)
throws MojoExecutionException, MojoFailureException, SurefireExecutionException,
SurefireBooterForkException, TestSetFailedException {
getConsoleLogger().debug("Using the provider " + provider.getProviderName());
SurefireProperties effectiveProperties = setupProperties();
ClassLoaderConfiguration classLoaderConfiguration = getClassLoaderConfiguration();
provider.addProviderProperties();
RunOrderParameters runOrderParameters =
new RunOrderParameters(getRunOrder(), getStatisticsFile(getConfigChecksum()), getRunOrderRandomSeed());
if (isNotForking()) {
Properties originalSystemProperties =
(Properties) System.getProperties().clone();
try {
createCopyAndReplaceForkNumPlaceholder(effectiveProperties, 1).copyToSystemProperties();
getConsoleLogger().debug("Using in-process starter");
InPluginVMSurefireStarter surefireStarter = createInprocessStarter(
provider,
classLoaderConfiguration,
runOrderParameters,
scanResult,
platform,
testClasspathWrapper);
return surefireStarter.runSuitesInProcess(scanResult);
} finally {
System.setProperties(originalSystemProperties);
}
} else {
ForkConfiguration forkConfiguration = createForkConfiguration(platform, resolvedJavaModularityResult);
if (getConsoleLogger().isDebugEnabled()) {
getConsoleLogger()
.debug("Using fork starter with configuration implementation "
+ forkConfiguration.getClass().getName());
showMap(getEnvironmentVariables(), "environment variable");
showArray(getExcludedEnvironmentVariables(), "excluded environment variable");
}
Properties originalSystemProperties =
(Properties) System.getProperties().clone();
ForkStarter forkStarter = null;
try {
forkStarter = createForkStarter(
provider,
forkConfiguration,
classLoaderConfiguration,
runOrderParameters,
getConsoleLogger(),
scanResult,
testClasspathWrapper,
platform,
resolvedJavaModularityResult);
return forkStarter.run(effectiveProperties, scanResult);
} catch (SurefireBooterForkException e) {
forkStarter.killOrphanForks();
throw e;
} finally {
System.setProperties(originalSystemProperties);
cleanupForkConfiguration(forkConfiguration);
}
}
}