Skip to content

Commit

Permalink
[SUREFIRE-1614] Fix corrupted stream warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sormuras committed Dec 12, 2018
1 parent de1c687 commit 938d422
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,29 @@ public Iterable<Class<?>> getSuites()
public RunResult invoke( Object forkTestSet )
throws TestSetFailedException, ReporterException
{
ReporterFactory reporterFactory = parameters.getReporterFactory();
RunListener runListener = reporterFactory.createReporter();

ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) runListener );

if ( forkTestSet instanceof TestsToRun )
{
return invokeAllTests( (TestsToRun) forkTestSet );
invokeAllTests( (TestsToRun) forkTestSet, runListener );
}
else if ( forkTestSet instanceof Class )
{
return invokeAllTests( TestsToRun.fromClass( (Class<?>) forkTestSet ) );
invokeAllTests( TestsToRun.fromClass( (Class<?>) forkTestSet ), runListener );
}
else if ( forkTestSet == null )
{
return invokeAllTests( scanClasspath() );
invokeAllTests( scanClasspath(), runListener );
}
else
{
throw new IllegalArgumentException( "Unexpected value of forkTestSet: " + forkTestSet );
}

return reporterFactory.close();
}

private TestsToRun scanClasspath()
Expand All @@ -130,22 +137,10 @@ private TestsToRun scanClasspath()
return parameters.getRunOrderCalculator().orderTestClasses( scannedClasses );
}

private RunResult invokeAllTests( TestsToRun testsToRun )
private void invokeAllTests( TestsToRun testsToRun, RunListener runListener )
{
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;
LauncherDiscoveryRequest discoveryRequest = buildLauncherDiscoveryRequest( testsToRun );
launcher.execute( discoveryRequest, new RunListenerAdapter( runListener ) );
}

private LauncherDiscoveryRequest buildLauncherDiscoveryRequest( TestsToRun testsToRun )
Expand Down

0 comments on commit 938d422

Please sign in to comment.