IntelliJ IDEA debugger skips breakpoints when debugging Maven tests

杀马特。学长 韩版系。学妹 提交于 2019-12-02 20:35:08
milan

One solution would be to use remote debugging:

  1. configure the surefire plugin: <debugForkedProcess>true</debugForkedProcess>;

  2. run the test (will wait for a remote debugger to connect)

  3. create and run a remote debug configuration in IntelliJ (will hit your breakpoint); the port to connect to is 5005.

Just disable the forked mode - something like this in your pom file (under project/build/plugins section):

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
    <forkMode>never</forkMode>
</configuration>
</plugin>

Your sources for the dependencies do not match the binary code. Make sure you're using the same sources.

If you're running unit tests with maven failsafe rather than surefire, then debugger will not stop and you have to manually run a failsafe debugger command line and then intellij will be able to stop on the breakpoints. I am unsure if using <forkMode>never</forkMode> option on failsafe solves this issue.

As I describe here: https://github.com/djangofan/maven-failsafe-debug-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!