Running Junit tests with jmockit in eclipse

Running Junit tests with jmockit in eclipse

Junit is a popular unit testing framework and jmockit is used to mock the objects.

eclipse is my favorite IDE (integrated development environment) software tool that provides writing, debug, deploy code and existing test cases.

eclipse provides different plugins like JUnit and maven plugins

After installing JUnit and Maven plugins to eclipse, we have to do following changes

JUnit and jmockit jars should be in the project classpath Add the test directory in your project to eclipse project build path, eclipse compiles successfully(‘Use as source folder’).

Please see below screenshot for adding java build path in eclipse

add java build path eclipse

Next step is to add the jmockit configuration to project JVM arguments To execute the test class, do right click and select Run dialog (Run As –> Open Run Dialog) and select Junit to execute tests keep default settings in dialog and create a JUnit test for the class and click on arguments tab. Add to vm arguments: ‘-javaagent:pathtothisjar/jmockit.jar’ (if using Maven, use ‘-javaagent:${env_var:HOME}/.m2/repository/jmockit/jmockit/1.0/jmockit-1.0.jar’) Click ‘Apply’ or click ‘Run’

jvm arguments configure

Please share this post if you like this post.


Thanks for this post.

Anonymous - Jan 3, 2015

Thanks for this post.

Similar Posts