I know that to run junit from command line you can do this:
java org.junit.runner.JUnitCore TestClass1 […other test classes…]
However, I want to run many tests together and manually typing “TestClass1 TestClass2 TestClass3…” is just inefficient.
Current I organize all test classes in a directory (which has sub-directories indicating the packages). Is there any way that I can run junit from command line and let it execute these test classes all at once?
Thanks.
I found that I can write an Ant buildfile to achieve this. Here is the sample build.xml:
With this build file, if you want to execute a single test, run:
If you want to execute multiple tests in batch, specify the corresponding tests under the
<batchtest>...</batchtest>as shown in the above example.