public static RunResult invokeProvider( Object testSet, ClassLoader testsClassLoader, Object factory, ProviderConfiguration providerConfiguration, boolean insideFork, StartupConfiguration startupConfig, boolean restoreStreams ) throws TestSetFailedException, InvocationTargetException { final PrintStream orgSystemOut = System.out; final PrintStream orgSystemErr = System.err; // Note that System.out/System.err are also read in the "ReporterConfiguration" instantiation // in createProvider below. These are the same values as here. try { return new ProviderFactory( startupConfig, providerConfiguration, testsClassLoader, factory ) .createProvider( insideFork ) .invoke( testSet ); } finally { if ( restoreStreams && System.getSecurityManager() == null ) { System.setOut( orgSystemOut ); System.setErr( orgSystemErr ); } } }
RunResult result = ProviderFactory.invokeProvider(null, createCombinedClassLoader(testPlugin), reporterFactory, providerConfiguration, false, startupConfiguration, true);
public RunResult runSuitesInProcess( @Nonnull DefaultScanResult scanResult ) throws SurefireExecutionException, TestSetFailedException { // The test classloader must be constructed first to avoid issues with commons-logging until we properly // separate the TestNG classloader Map<String, String> providerProperties = providerConfig.getProviderProperties(); scanResult.writeTo( providerProperties ); startupConfig.writeSurefireTestClasspathProperty(); ClassLoader testClassLoader = startupConfig.getClasspathConfiguration() .toRealPath( ClasspathConfiguration.class ) .createMergedClassLoader(); CommonReflector surefireReflector = new CommonReflector( testClassLoader ); Object factory = surefireReflector.createReportingReporterFactory( startupReportConfig, consoleLogger ); try { return invokeProvider( null, testClassLoader, factory, providerConfig, false, startupConfig, true ); } catch ( InvocationTargetException e ) { throw new SurefireExecutionException( "Exception in provider", e.getTargetException() ); } }
private Iterable<Class<?>> getSuitesIterator() throws SurefireBooterForkException { try { AbstractPathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); ClassLoader unifiedClassLoader = classpathConfiguration.createMergedClassLoader(); CommonReflector commonReflector = new CommonReflector( unifiedClassLoader ); Object reporterFactory = commonReflector.createReportingReporterFactory( startupReportConfiguration, log ); ProviderFactory providerFactory = new ProviderFactory( startupConfiguration, providerConfiguration, unifiedClassLoader, reporterFactory ); SurefireProvider surefireProvider = providerFactory.createProvider( false ); return surefireProvider.getSuites(); } catch ( SurefireExecutionException e ) { throw new SurefireBooterForkException( "Unable to create classloader to find test suites", e ); } }
public RunResult runSuitesInProcess( @Nonnull DefaultScanResult scanResult ) throws SurefireExecutionException, TestSetFailedException { // The test classloader must be constructed first to avoid issues with commons-logging until we properly // separate the TestNG classloader Map<String, String> providerProperties = providerConfig.getProviderProperties(); scanResult.writeTo( providerProperties ); startupConfig.writeSurefireTestClasspathProperty(); ClassLoader testClassLoader = startupConfig.getClasspathConfiguration() .toRealPath( ClasspathConfiguration.class ) .createMergedClassLoader(); CommonReflector surefireReflector = new CommonReflector( testClassLoader ); Object factory = surefireReflector.createReportingReporterFactory( startupReportConfig, consoleLogger ); try { return invokeProvider( null, testClassLoader, factory, providerConfig, false, startupConfig, true ); } catch ( InvocationTargetException e ) { throw new SurefireExecutionException( "Exception in provider", e.getTargetException() ); } }
private Iterable<Class<?>> getSuitesIterator() throws SurefireBooterForkException { try { AbstractPathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); ClassLoader unifiedClassLoader = classpathConfiguration.createMergedClassLoader(); CommonReflector commonReflector = new CommonReflector( unifiedClassLoader ); Object reporterFactory = commonReflector.createReportingReporterFactory( startupReportConfiguration, log ); ProviderFactory providerFactory = new ProviderFactory( startupConfiguration, providerConfiguration, unifiedClassLoader, reporterFactory ); SurefireProvider surefireProvider = providerFactory.createProvider( false ); return surefireProvider.getSuites(); } catch ( SurefireExecutionException e ) { throw new SurefireBooterForkException( "Unable to create classloader to find test suites", e ); } }