{
if (classMultiScriptAnnotation == null) {
return statement;
} else {
BMScript[] scriptAnnotations = classMultiScriptAnnotation.scripts();
Statement result = statement;
// note we iterate down here because we generate statements by wraparound
// which means the the outer statement gets executed first
for (int i = scriptAnnotations.length; i> 0; i--) {
BMScript scriptAnnotation= scriptAnnotations[i - 1];
final String name = computeBMRulesName(scriptAnnotation.value(), testKlazz);
final RunNotifier fnotifier = notifier;
final Description description = Description.createTestDescription(testKlazz, getName(), scriptAnnotation);
final String loadDirectory = normaliseLoadDirectory(scriptAnnotation);
final Statement nextStatement = result;
result = new Statement() {
public void evaluate() throws Throwable {
try {
BMUnit.loadScriptFile(testKlazz, name, loadDirectory);
try {
nextStatement.evaluate();
} finally {
try {
BMUnit.unloadScriptFile(testKlazz, name);
} catch (Exception e) {
fnotifier.fireTestFailure(new Failure(description, e));