停止 Maven 在编译时运行测试 IntelliJ

huangapple go评论74阅读模式
英文:

Stopping maven from running test while compiling intellij

问题

我的代码在编译时一直在运行测试,但单元测试失败了,我试图调试它,但无法找到错误的配置在哪里。我已经在整个互联网上搜索过了,但也许是我关键词不对。

TLDR:我的代码无法编译,因为当前的单元测试失败了,我无法调试单元测试,因为无法构建我的项目。

英文:

I am having a problem regarding my code keeps on running test while compiling the code but the unit test is wrong and I am trying to debug it but I can't. Where to look for the wrong configuration? I have search the whole internet for it but maybe my keyword is wrong.

TLDR: My code cannot compile because my current Unit Test is failed, I cannot debug the unit test because I can't build my project.

答案1

得分: 0

我认为你可以在`pom.xml`中的maven插件中添加一个跳过测试的配置。例如:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>

然后当你重新运行项目时,单元测试将不会运行。
或者你可以在命令行中以另一种方式编译你的项目。

mvn package -Dmaven.test.skip=true

这个命令既不会编译单元测试代码,也不会运行单元测试。
英文:

I think you can add a skip tests configuration in your maven plugin in pom.xml. for example :

&lt;plugin&gt;
    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
    &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
    &lt;version&gt;2.9&lt;/version&gt;
    &lt;configuration&gt;
        &lt;skipTests&gt;true&lt;/skipTests&gt;
    &lt;/configuration&gt;
&lt;/plugin&gt;

Then when you rerun the project, the unit tests will not run.
Or you just can compile your project in another way in the command line.

mvn package -Dmaven.test.skip=true  

This command will nether compile the unit test code ,nor run the unit test.

答案2

得分: 0

尝试安装Maven扩展并关闭测试跳过测试模式。

英文:

Try With Install Maven Extension and Turn off Test Toggle skip Tests Mode.

答案3

得分: 0

在IntelliJ Idea中,转到设置 > 构建、执行、部署 > 构建工具 > Maven > 运行器,取消勾选“将IDE构建/运行操作委托给Maven”。就这样。

英文:

I have found the answer for anyone who stumbles upon the same problem.
In IntelliJ Idea > Settings > Build, Execution, Deployment > Build Tools > Maven > Runner > UN-TICK Delegate IDE build/run actions to Maven

That's it.

huangapple
  • 本文由 发表于 2023年3月23日 12:25:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75819242.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定