public void run( RunNotifier notifier ) {
for ( Scenario scenario : scenarios ) {
Description childDescription = Description.createTestDescription( getClass(),
scenario.getName() );
descr.addChild( childDescription );
EachTestNotifier eachNotifier = new EachTestNotifier( notifier,
childDescription );
try {
eachNotifier.fireTestStarted();
//If a KieSession is not available, fail fast
if ( ksession == null ) {
throw new NullKieSessionException( "Unable to get a Session to run tests. Check the project for build errors." );
} else {
final ScenarioRunner runner = new ScenarioRunner( ksession,
maxRuleFirings );
runner.run( scenario );
if ( !scenario.wasSuccessful() ) {
StringBuilder builder = new StringBuilder();
for ( String message : scenario.getFailureMessages() ) {
builder.append( message ).append( "\n" );
}
eachNotifier.addFailedAssumption( new AssumptionViolatedException( builder.toString() ) );
}
}
} catch ( Throwable t ) {
eachNotifier.addFailure( t );
} finally {
// has to always be called as per junit docs
eachNotifier.fireTestFinished();
}
}
}