}
customRunListeners.add( 0, getRunListener( reporterFactory, consoleLogger ) );
// Add test failure listener
JUnitTestFailureListener testFailureListener = new JUnitTestFailureListener();
customRunListeners.add( 0, testFailureListener );
JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners, filter );
// Rerun failing tests if rerunFailingTestsCount is larger than 0
if ( rerunFailingTestsCount > 0 )
{
for ( int i = 0; i < rerunFailingTestsCount && !testFailureListener.getAllFailures().isEmpty(); i++ )
{
Map<Class<?>, Set<String>> failingTests =
JUnit4ProviderUtil.generateFailingTests( testFailureListener.getAllFailures(), testsToRun );
testFailureListener.reset();
final FilterFactory filterFactory = new FilterFactory( testClassLoader );
Filter failingMethodsFilter = filterFactory.createFailingMethodFilter( failingTests );
JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners,
filterFactory.and( filter, failingMethodsFilter ) );
}