@Test
public void surefireIsConfused_ByMultipleIgnore_OnClassLevel()
throws Exception
{
ReporterFactory reporterFactory = DefaultReporterFactory.defaultNoXml();
BaseProviderFactory providerParameters = new BaseProviderFactory( reporterFactory, true );
ConsoleLogger consoleLogger = new DefaultConsoleReporter( System.out );
providerParameters.setReporterConfiguration( new ReporterConfiguration( new File( "" ), false ) );
Properties junitProps = new Properties();
junitProps.put( ProviderParameterNames.PARALLEL_PROP, "none" );
JUnitCoreParameters jUnitCoreParameters = new JUnitCoreParameters( junitProps );
final Map<String, TestSet> testSetMap = new ConcurrentHashMap<String, TestSet>();
RunListener listener =
ConcurrentRunListener.createInstance( testSetMap, reporterFactory, false, false, consoleLogger );
TestsToRun testsToRun = new TestsToRun( Arrays.<Class>asList( TestClassTest.class ) );
org.junit.runner.notification.RunListener jUnit4RunListener = new JUnitCoreRunListener( listener, testSetMap );
List<org.junit.runner.notification.RunListener> customRunListeners =
new ArrayList<org.junit.runner.notification.RunListener>();
customRunListeners.add( 0, jUnit4RunListener );
try
{
// JUnitCoreWrapper#execute() is calling JUnit4RunListener#rethrowAnyTestMechanismFailures()
// and rethrows a failure which happened in listener
exception.expect( TestSetFailedException.class );
JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners, null );
}
finally
{
RunResult result = reporterFactory.close();
Assert.assertEquals( "JUnit should report correctly number of test ran(Finished)",
1, result.getCompletedCount() );
}
}