Search code examples
javacode-coveragejacocomaven-surefire-pluginjmockit

How to disable jmockit coverage instrumentation


I have a maven project where jmockit 1.18 is used for mocking, surefire for running test suites and jacoco for measuring code coverage.

When I try to upgrade jmockit to version 1.45, it gives error while initializing test suite runner VM. However tests get executed when javaagent is explicitly passed as argline param.

Can someone tell me if there is a way to disable jmockit instrumentation or agent initialization?


Solution

  • The JMockit release notes explicitly say

    Version 1.42 (Aug 26, 2018):
    JMockit now requires the use of the "-javaagent" JVM initialization parameter.


    The Running tests with JMockit chapter says

    To run tests that use any of the JMockit APIs
    ...
    Configure the test execution JVM to start with the "-javaagent:/jmockit.1.x.jar" parameter.


    Which means that you're forced using that VM startup parameter.
    At least if you want to keep using JMockit.