如何使用 maven 构建 jar,忽略测试结果? [英] How to build a jar using maven, ignoring test results?

查看:10
本文介绍了如何使用 maven 构建 jar,忽略测试结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,当我运行测试时,它们失败了,但我需要运行它们来获取一些对我的 jar 非常重要的 .class 文件.

Actuality when i run tests they fails but i need to run them to get some .class files which are very important for my jar.

默认情况下,当测试结果失败时,jar 不会构建,我可以在 pom.xml 中添加一个忽略它的设置,这样我就可以构建 jar 忽略测试结果吗?

By default when test results fails , the jar is not build , could i add a setting in pom.xml which ignore that, so I can build the jar ignoring results from tests ?

我读了一些关于Maven Surefire Plugin"的内容,但我不知道如何使用它...

I read something about "Maven Surefire Plugin" but I don't know how to use it...

推荐答案

请参考 surefire:test 了解详情,但最有用的属性是:

Please refer to surefire:test for details, but the most useful properties are:

-Dmaven.test.failure.ignore=true(或 -DtestFailureIgnore=true) - 将忽略测试执行期间发生的任何失败

-Dmaven.test.failure.ignore=true (or -DtestFailureIgnore=true) - will ignore any failures occurred during test execution

-Dmaven.test.error.ignore=true(不推荐使用)- 将忽略测试执行期间发生的任何错误

-Dmaven.test.error.ignore=true ( deprecated ) - will ignore any errors occurred during test execution

-DskipTests - 将编译测试类但完全跳过测试执行

-DskipTests - would compile the test classes but skip test execution entirely

-Dmaven.test.skip=true - 甚至不会编译测试

-Dmaven.test.skip=true - would not even compile the tests

我相信在您希望编译测试类但不会由于任何测试错误而导致构建失败并且仍然创建 jar 的情况下.

I believe that in your case where you want to compile test classes but not fail the build due to any tests errors and still create the jar.

您应该使用第一个选项来忽略任何测试失败,一旦构建完成,您仍然可以查看这些失败.

You should use the first option to ignore any test failures which you can still review once the build has finished.

这篇关于如何使用 maven 构建 jar,忽略测试结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆