Monday, 9 April 2012

JDK7 EJB3.1 and Netbeans Project (Part III) - Testing

Part I - Introduction, Part II - Hibernate and Transactions, Part III - Testing

Netbeans + TestNG

I have been trying out TestNG and JMockit in the new Netbeans. [1]

TestNG has become a standard part of Netbeans, that is, if you download the Nightly builds[2] of Netbeans. There is no longer a need to install the plugin from contrib. I used it, and I was suitably impressed.

In Bugzilla you can file bugs under "java/TestNG".


I do like adding JMockit to my testing, because I've gotten used to mocking all the classes that I am not interested in and being able to provide their behavior in the tests. Especially handy to prevent having to use a database.

In this case, this was easy as pie. Just download[3] and add the jmockit.jar to the testing libraries, and away I went.


An example of what the results look like in Netbeans can be viewed at [2]. I like the test reports generated, though, they provide a deal more information on what is going wrong.


[1] Netbeans - TestNG
[2] Netbeans - Nightly Builds
[3] JMockit
The JMockit Testing Toolkit Tutorial
Unit Testing With TestNG and JMockit