Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jMockit Report generation Fails with maven-surefire-plugin #743

Open
mlr28 opened this issue Apr 12, 2023 · 0 comments
Open

jMockit Report generation Fails with maven-surefire-plugin #743

mlr28 opened this issue Apr 12, 2023 · 0 comments

Comments

@mlr28
Copy link

mlr28 commented Apr 12, 2023

My project is a multi-module project.

I am trying to generate a test coverage report with jmockit within maven-surefire-plugin

When I build my maven project from the base directory : mvn clean package or mvn clean install, I get the following error

[INFO] Results:
[INFO]
[ERROR] Errors: 
[ERROR]   RestControllerTest.createA_PositiveWorkflow:61 ExceptionInInitializer
[ERROR]   RestControllerTest.getAById_PositiveWorkflow:98 NoClassDefFound Could not initialize class mockit.Expectations
[ERROR]   RestValidatorTest.validateA1:96 NoClassDefFound Could not initialize class mockit.Expectations
[ERROR]   RestValidatorTest.validateA2:115 NoClassDefFound Could not initialize class mockit.Expectations
[ERROR]   RestValidatorTest.validateA3:62 NoClassDefFound Could not initialize class mockit.Expectations
[ERROR]   RestValidatorTest.validateA4:79 NoClassDefFound Could not initialize class mockit.Expectations
[INFO]
[ERROR] Tests run: 16, Failures: 0, Errors: 6, Skipped: 0
[INFO]
[ERROR]

Java Version : Eclipse Temurin 17.0.5.8-hotspot

Maven Version : 3.6.3

Test Dependencies : jUnit, jMockit

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jmockit</groupId>
        <artifactId>jmockit</artifactId>
        <version>${jmockit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jmockit</groupId>
        <artifactId>jmockit-coverage</artifactId>
        <version>1.23</version>
        <scope>test</scope>
    </dependency>
   
   <!-- Propeties-->
   <java.release>17</java.release>
   <spring.boot.version>3.0.2</spring.boot.version>
   <spring.version>6.0.4</spring.version>
   <junit.version>5.9.2</junit.version>
  <jmockit.version>1.49</jmockit.version>

Below is my jMockit Coverage configured in maven-surefire-plugin

     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <argLine>
                -javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
            </argLine>
            <systemPropertyVariables>
                <coverage-output>html</coverage-output>
                <coverage-outputDir>target/coverage-report</coverage-outputDir>
                <coverage-classes>com.package.api.*</coverage-classes>
                <coverage-excludes>com.package.api.constant.*,com.package.api.dto.*,com.package.api.model.*</coverage-excludes>
            </systemPropertyVariables>
            <argLine>--illegal-access=permit</argLine>
            <testFailureIgnore>true</testFailureIgnore>
        </configuration>
    </plugin>

Please let me know what else I need to do to generate report in defined Output directory.

Note : Running All tests from Intellij Run generated html report but not during Maven build.

Thanks in Advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant