jmockit / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
458 stars 238 forks source link

Issue with Jmockit 1.49 and IntelliJ 2021.1.1 #711

Open modiboa opened 3 years ago

modiboa commented 3 years ago

The tests are running fine with mvn verify in the command line, but when I try to run using IntellJ I got the following error

Exception in thread "main" java.lang.StackOverflowError
    at mockit.internal.faking.FakeStates.getFakeState(FakeStates.java:93)
    at mockit.internal.faking.FakeInvocation.create(FakeInvocation.java:31)
    at org.junit.runner.notification.RunNotifier.fireTestRunStarted(RunNotifier.java)
    at mockit.integration.junit4.FakeRunNotifier.fireTestRunStarted(FakeRunNotifier.java:37)
    at org.junit.runner.notification.RunNotifier.fireTestRunStarted(RunNotifier.java)
    at mockit.integration.junit4.FakeRunNotifier.fireTestRunStarted(FakeRunNotifier.java:37)
    at org.junit.runner.notification.RunNotifier.fireTestRunStarted(RunNotifier.java)
    at mockit.integration.junit4.FakeRunNotifier.fireTestRunStarted(FakeRunNotifier.java:37)
    at org.junit.runner.notification.RunNotifier.fireTestRunStarted(RunNotifier.java)
    at mockit.integration.junit4.FakeRunNotifier.fireTestRunStarted(FakeRunNotifier.java:37)
    at org.junit.runner.notification.RunNotifier.fireTestRunStarted(RunNotifier.java)
    at mockit.integration.junit4.FakeRunNotifier.fireTestRunStarted(FakeRunNotifier.java:37)

Process finished with exit code 1

Junit 4.12

Anyone has any ideas?

modiboa commented 3 years ago

After some testing, I found that if I set the maven-surefire-plugin configuration in the parent pom.xml I got the exception, but if I move the configuration to the child pom (module where the tests are) I can run fine with IntelliJ (Ctrl+Shit+F10).

My configuration:

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>
                        -javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
                    </argLine>
                </configuration>
            </plugin>
        </plugins>
    </build>

ps: I tested adding the configuration inside parent pom <plugins> and <pluginManagement> as well...

modiboa commented 3 years ago

It seems the root cause is when the project uses both maven-surefire-plugin and maven-failsafe-plugin with a configured <argLine>. I think what happens is that IntelliJ will automatically add the <argLine> from both plugins into the Test Runner.

If I disabled the argLine option I got the error of not found argLine. But If I enabled I got the exception above Screenshot from 2021-05-04 16-01-26

modiboa commented 3 years ago

I commented about this in the IntelliJ issue tracker https://youtrack.jetbrains.com/issue/IDEA-199109

bilak commented 3 years ago