在IntelliJ中,我如何调试maven测试目标?

时间:2022-01-02 17:14:48

Using intellij and maven pom files, how do i debug tests run inside the maven test goal?

使用intellij和maven pom文件,如何在maven测试目标内调试运行测试?

When i run them directly in the code, it complains something about profiles missing, which i've ticked inside intellij's Maven Projects.

当我在代码中直接运行它们时,它会抱怨缺少了概要文件,我已经在intellij的Maven项目中进行了注释。

5 个解决方案

#1


21  

What about a right click on your goal and "Debug [your goal]" (in your case the test goal)?

在你的目标上点击右键,“调试(你的目标)”(在你的测试目标中)?

在IntelliJ中,我如何调试maven测试目标?

#2


133  

http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html

http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html

In IDEA, run your test in debug mode "mvn -DforkMode=never test"

在IDEA中,在调试模式下运行您的测试“mvn -DforkMode=never test”

Updated: Open your run/debug configuration, in "Runner" tab, add -DforkMode=never

更新:打开您的运行/调试配置,在“Runner”选项卡中,添加-DforkMode=never。

在IntelliJ中,我如何调试maven测试目标?

(Noted by @mikeapr4: newer versions of the surefire plugin (2.14+) use mvn -DforkCount=0 test)

(@mikeapr4指出:surefire插件的更新版本(2.14+)使用mvn -DforkCount=0测试)

#3


20  

I execute tests with the following options:

我使用以下选项执行测试:

mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=6666 -Xnoagent -Djava.compiler=NONE" test

... and then connect to Maven with remote debugger.

…然后用远程调试器连接到Maven。

#4


9  

-DforkMode=never doesn't work anymore, it is now deprecated in SureFire.

-DforkMode=永远不会停止工作,它现在已经在SureFire中被弃用了。

Use -DforkCount=0 instead when using surefire plugin 2.14+.

在使用surefire插件2.14+时使用-DforkCount=0。

#5


7  

The question has been answered. But just to share my own experience. The selected answer did not solve my problem. My code has multiple modules.

这个问题已经回答了。只是分享我自己的经验。选择的答案并不能解决我的问题。我的代码有多个模块。

foolshat's reply did bring valuable insight to my problem.

傻瓜的回答确实给我的问题带来了有价值的见解。

I have two solutions, 1. Using your IDEA, by adding a VM option -DforkMode=never; Must run it with debug mode. 2. Set up a remote debugging, specifying the socket and in this case forkMode is not necessary.

我有两个解,1。使用您的想法,通过添加VM选项-DforkMode=never;必须以调试模式运行它。2。设置远程调试,指定套接字,在这种情况下不需要forkMode。

It is just a summary for what I have been through.

这只是对我所经历的事情的总结。

#1


21  

What about a right click on your goal and "Debug [your goal]" (in your case the test goal)?

在你的目标上点击右键,“调试(你的目标)”(在你的测试目标中)?

在IntelliJ中,我如何调试maven测试目标?

#2


133  

http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html

http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html

In IDEA, run your test in debug mode "mvn -DforkMode=never test"

在IDEA中,在调试模式下运行您的测试“mvn -DforkMode=never test”

Updated: Open your run/debug configuration, in "Runner" tab, add -DforkMode=never

更新:打开您的运行/调试配置,在“Runner”选项卡中,添加-DforkMode=never。

在IntelliJ中,我如何调试maven测试目标?

(Noted by @mikeapr4: newer versions of the surefire plugin (2.14+) use mvn -DforkCount=0 test)

(@mikeapr4指出:surefire插件的更新版本(2.14+)使用mvn -DforkCount=0测试)

#3


20  

I execute tests with the following options:

我使用以下选项执行测试:

mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=6666 -Xnoagent -Djava.compiler=NONE" test

... and then connect to Maven with remote debugger.

…然后用远程调试器连接到Maven。

#4


9  

-DforkMode=never doesn't work anymore, it is now deprecated in SureFire.

-DforkMode=永远不会停止工作,它现在已经在SureFire中被弃用了。

Use -DforkCount=0 instead when using surefire plugin 2.14+.

在使用surefire插件2.14+时使用-DforkCount=0。

#5


7  

The question has been answered. But just to share my own experience. The selected answer did not solve my problem. My code has multiple modules.

这个问题已经回答了。只是分享我自己的经验。选择的答案并不能解决我的问题。我的代码有多个模块。

foolshat's reply did bring valuable insight to my problem.

傻瓜的回答确实给我的问题带来了有价值的见解。

I have two solutions, 1. Using your IDEA, by adding a VM option -DforkMode=never; Must run it with debug mode. 2. Set up a remote debugging, specifying the socket and in this case forkMode is not necessary.

我有两个解,1。使用您的想法,通过添加VM选项-DforkMode=never;必须以调试模式运行它。2。设置远程调试,指定套接字,在这种情况下不需要forkMode。

It is just a summary for what I have been through.

这只是对我所经历的事情的总结。