This week I met a task, that is: I have one test case (with contains logistics) and multiple group of test data combinations. So I want to make use of JUnit Parameterized Test Function to test all and generate splendid report. How ever, when I invoke the standard Parameteried Tests in JUnit4, a problem occured:
The displaying name of each round test in the report is : , ,  ….
All my collegues think this naming tradition of JUnit is meaningless. What we want is : test[A=a;B=b…], test[A=1;B=2…] …, from which users can easily understand with what kind of value combination the test failed. I googled the problem, many people have the same requirement. From StackOverflow , someone already made a customized JUnit Test Runner “LabelledParameterized”, by which the displaying name of JUnit Result can be changed by users’ code. I download the source code, and test it. Good news is that it works in Eclipse (3.6) with Junit.jar (4.10). Bad news is that it does not work in Netbeans (7.1) nor ANT (by JUNIT/JUNIT REPORT Target).
So I have to keep finding. Then I found JUnitParams Project from Google Code. By which the displaying name is successfully replaced both in IDE (eclipse/netbeans) and command line mode (ANT). By the way, JUnitParams is not perfect yet, the displaying name will be mysterious if all your parameters are “String” type.
To Compare the differences of each Test Runner, I made a comparison project (wiht ANT build.xml). You can download it from Here. Just unzip the code to local folder (without space in path name), and run the build.xml (Target “all”) from ANT. Here are some screen snapshots.
Result Comparison in Eclipse
Result Comparison in html Report (generated by ANT – JUnitReport)