Hello, Not fond in the existing bugs or RFE. I try to solve the following problem. We have some hundreds of unit tests running. It happens that one of them takes a lot of time to run or is blocked. In an IDE like Eclipse, I can see which test is running in the Junit window. When I run the tests through the Junit task of Ant, I cannot. I have to wait for the test report. Junit provides a way to add one or more RunListener instances (http://junit.sourceforge.net/javadoc_40/org/junit/runner/notification/RunListener.html) to a JunitCore object. The Junit RunNotifier class allows also to add some notifiers. The problem is that I do not have any hook to do this at all while the runner used by Ant has normally access to these classes. I even suppose that it already takes advantage of them. What I suggest is to add to the Junit task an optional attribute, which would be a comma delimited list of listener FQN (or if you prefer a single one a one could call others). e.g. <junit runlistener="com.acme.MyListener"> ... </junit> With this I am free to do anything that I want, report a progress in one or many log files, timing my tests, detect a problem and link it to a precise test... Thanks Olivier
...and with the FQN avaialble, the Junit runner can create an instance of it and add it after the other listeners. It should to the trick. Olivier
Could you please elaborate what is not feasible using the current options, most notably the formatter element?
Hello, I still want the output to be sent to the XML formatter as now. I just want some additional behavior. I suppose that the plain formatter could give some details but I do not want to run the unit tests twice, it takes already long enough. I just want some information during the tests that I can log where I want. Multiple RunListeners can be used. I guess that you already use one of them for your formatter. I just to want the option to add mine to the one of the formatter. The other option I now think of is to extend/decorate the XML formatter. This could be fine but if I need to change to a different formatter for any reason, I need to redo my work. The listener solution would be more flexible I think. Thanks Olivier
Olivier, do you realize that you can add more than one formatter element to the junit task and thus can add more than one formatter during a single test run? And then formatter supports a classname attribute that you can use to attach any class that implements the JUnitResultFormatter interface (an extension of junit-framework.TestListener) to the running tests.
It really seems as if all the functionality you are asking for is already there (use multiple formatters). What is missing?
Hi Stefan, I have just tested according to your suggestion, creating a class extending BriefJUnitResultFormatter and decorating it to log the test being started or other then putting it in a jar file added to the classpath. It works perfectly, I can now see the progress of the tests. Thanks a lot, I had not realized from the documentation that multiple formatters could be used. I close the request Olivier