简体   繁体   中英

ANT : JMockIt mocking is not working

Test cases are written using JMockIt to mock complex behavior. Mocking is working as expected when test cases are executed using eclipse.

But when test cases are executed using ANT, mocking is not working as expected since mocking mocking method throws Exception.

In Ant build script launchJunit task is used instead of junit task, to execute the Junit test cases.

As per analysis, root cause seems to be build script launches JRE to execute test cases and JRE does not have tools.jar file. I added tools.jar file in my application classpath but still problem is not solved.

Java home point to correct JDK but as per ant diagnostic tool java home is %JAVA_HOME%/jre. Property env.JAVA_HOME = %JAVA_HOME% correct JDK Property java.home = %JAVA_HOME%/jre

I am getting most of the hint to solve problem for junit task but not came across any solution of launchJunit task.

Is my understanding of the problem is correct and how to resolve issue?

I also meet your case.When i run jmockit in junit eclipse plugins, it works. But switch to the ant task, it halts in junit task, no error, either no info. So i check all the classpath and environment variable in the ant xml and eclipse junit lancher. When i make them same config, it turns to be ok! I think you can try my way, just check the classpath and variable in the two cases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM