I'm trying to execute some Arquillian tests from Ant (1.8.2, with junit4 support) but it seems that the Ant task does not call RunNotifier.fireTestRunFinished() and the Arquillian test runner counts on this to undeploy the arquillian-jmx war from the container. The Eclipse integration of JUnit calls the fireRestRunFinished methods and everything works correctly from there.
I looked around the junit javadoc and saw this in RunNotifier:
public void fireTestRunFinished(Result result)
Do not invoke.
Moreover, the class javadoc description says this:
Future evolution of this class is likely to move fireTestRunStarted(Description) and fireTestRunFinished(Result) to a separate class since they should only be called once per run.
but it doesn't specify where will it be moved.
Looking around the sourcecode of junit, I saw that the only place where fireTestRunFinished is invoked is inside this method:
/**
* Do not use. Testing purposes only.
*/
public Result run(Runner runner) {
Result result= new Result();
RunListener listener= result.createListener();
fNotifier.addFirstListener(listener);
try {
fNotifier.fireTestRunStarted(runner.getDescription());
runner.run(fNotifier);
fNotifier.fireTestRunFinished(result);
} finally {
removeListener(listener);
}
return result;
}
As you can see, it says...do not invoke.
My question is, what is JUnit planning to do about notifying custom runners when all tests have finished running? If this current API isn't used, is there anything else available? Right now my options are either modify the Arquillian runner to not depend on a RunListener anymore or the ant task to call the RunNotifier.fireTestRunFinished. Either way, I have to change code I don't own...and that's obviously not my first option.
...or I can extend the Arquillian runner, override the run() method and do what the RunListener does after super.run().
Does anyone see any other way around this?