How do I capture and save the results of a JUnit 4 test suite run?
Posted on 2007-12-03
Hello, I have created a test suite using JUnit 4. It uses JUnit 4 annotations so it is essentially an empty class that looks like this:
public class MySuite
I'm developing in Eclipse and when I execute this as a JUnit test everything works. The only problem is that ultimately I want this to run in an automated environment after installation on a machine where there will be no eclipse set up. Essentially I want to wrap the execution of this test suite in a script (possibly using Ant, not sure yet). Further, I want to capture the results of each test and store them in an HTML file that I can then look at the results using a browser.
Question: how can I capture the results of the tests in the suite when my test suite class does not even have a body to it?
I looked into writing a class that extended Runner but without much success. It seems that I am missing something. Has anybody else done anything like this?
I have also experimented with building the suite using the JUnit 3 pattern of building a test suite, but that seems to break since my test case classes (TestClass1 and TestClass2) are using JUnit 4 annotations. JUnit 4 does not seem to like being mixed with JUnit 3.
Thanks in advance,