Saturday, May 26, 2012

JMockit Tutorial: How to run a test case with JMockit?

This tutorial assumes that the jmockit.jar is already in the projects build path. If you want to know how to do it.You can find it here

 Adding the java agent argument

Since JMockit uses instrumentation apis, we need to add the java agent in the VM argument.

Assume the jmockit.jar is present in the directory C:\jmockit\jmockit.jar and you will be running ViewTest class as a JUnit test.


Then  in the Run Configurations window add to VM arguments "-javaagent:C:\jmockit\jmockit.jar" as shown in the screen shot below.



Then click on Apply and then Run.

Hope this tutorial makes things easier for you .If you have any questions please post, I'll be happy to answer.

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. If we are using maven, and added the jMockit dependency artifact, do we still need to use jar in VM args? or we can run as junit directly?

    ReplyDelete