package models.jbehave;

import play.test.TestServer;
import play.test.Helpers;

public class JBehaveRunnerAssistant extends JBehaveRunnerCommandLine {

    private TestServer server;

    public static void main(String[] args) throws Throwable {
        JBehaveRunnerAssistant cpRunner = new JBehaveRunnerAssistant();
        if (!cpRunner.isHelp(args)) {
            JBehaveRunner runner = cpRunner.getRunner(args);
            try {
                cpRunner.startFakeApp();
                runner.run();
                runner.cleanUp();
                cpRunner.stopFakeApp();
            } catch (Throwable e) {
                runner.cleanUp();
                cpRunner.stopFakeApp();
                throw e;
            }
        }
    }

    public void startFakeApp() {
        server = Helpers.testServer(1234, Helpers.fakeApplication());
        Helpers.start(server);
    }

    public void stopFakeApp() {
        Helpers.stop(server);
    }

}

@@ -324,37 +324,111 @@
     
-if (!cpRunner.isHelp(args)) %7B
+System.out.println(%22111%22);%0A        if (!cpRunner.isHelp(args)) %7B%0A            System.out.println(%22222%22);
 %0A   
@@ -485,16 +485,55 @@
 (args);%0A
+            System.out.println(%22333%22);%0A
         
@@ -575,32 +575,75 @@
 startFakeApp();%0A
+                System.out.println(%22444%22);%0A
                 
@@ -668,39 +668,48 @@
             
-runner.cleanUp(
+System.out.println(%22444%22
 );%0A         
@@ -731,32 +731,184 @@
 .stopFakeApp();%0A
+                System.out.println(%22555%22);%0A                runner.cleanUp();%0A                System.out.println(%22666%22);%0A                System.exit(0);%0A
             %7D ca
@@ -939,39 +939,48 @@
             
-runner.cleanUp(
+System.out.println(%22777%22
 );%0A         
@@ -1030,40 +1030,159 @@
     
-throw e;%0A            %7D%0A        %7D
+System.out.println(%22888%22);%0A                runner.cleanUp();%0A                System.exit(1);%0A            %7D%0A        %7D%0A        System.out.println(%22000%22);
 %0A   

Change the runner so that exit is forced within the main.