I have spent a couple of hours this weekend on a new approach to running JUnit 3.x tests in TestNG
Previously, we have tried to emulate through TestNG the behavior of JUnit and things were quite complex. Also, considering how many extensions are there for JUnit we have never been sure we are able to run all existing JUnit tests.
So, I decided to give it another try and see if I can come out with a better approach. And instead of trying to emulate JUnit runtime behavior, I thought I can handle JUnit tests to JUnit itself and just make it report back the results. After a couple of hours of hacking I got it working and right now I think we will be able to run an even bigger percentage of existing JUnit code. And as a validation of the changes, I have run not only the TestNG tests (almost 300), but also JUnit internal tests (131) and all passed.
This new revamped support for JUnit will be released in the next version, but if you want to challenge it please feel free to build it yourself from the SVN trunk (or drop me an email) and put it to extensive work.

4 Comments
September 5, 2006 at 9:09 pm
“I thought I can handle JUnit tests to JUnit itself and just make it report back the results.”>
Alex:
Thru ITestListener in TestNG, can Junit hack that you’ve done report back pass/fail as the test runs or you only gets a report after all tests have ran?.
-BK-
September 5, 2006 at 9:18 pm
Everything is “real-time” :-]. I mean JUnit reports back to TestNG in real time and TestNG triggers its events as normal.
./alex
–
.w( the_mindstorm )p.
September 6, 2006 at 2:16 am
Alex:
Thanks. Will this be released in TestNG 5.2?
thanks,
-BK-
September 22, 2006 at 10:00 pm
Yes, it is included with the TestNG 5.2 release.
./alex
–
.w( the_mindstorm )p.