如何自动运行mvn测试(无需重建源代码)? [英] How can I atomically run mvn tests (without rebuilding source code)?

查看:150
本文介绍了如何自动运行mvn测试(无需重建源代码)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行一个Maven项目生命周期,从单元测试开始到结束.

I want to run a maven project lifecycle starting, and ending, with the unit tests.

如何跳过重新编译和重新解析依赖项,而仅运行测试阶段?

How can I skip recompilation and re-resolution of dependencies and only run the test phase?

推荐答案

如果通过调用一个阶段来启动Maven,它将执行所有生命周期阶段,直到您要调用的阶段为止.例如,当致电

If you start maven by calling a phase it will execute all lifecycle phases up to the one you are calling. For example, when calling

mvn test

也将执行测试生命周期阶段之前的所有阶段:将验证项目,将生成和处理源和资源,将对源进行编译,对源和资源进行同样的测试,最后将进行单元测试运行.

all the phases before the test lifecycle phase will be execute too: the project will be validated, sources and resources will be generated and processed, sources will be compiled, the same will happen to test sources and resources and finally unit tests will be run.

但是您也可以调用绑定到生命周期阶段的插件目标.在测试阶段,绑定目标是surefire的测试mojo.所以你可以打电话

But you can also call the plugin goal that is bound to a lifecycle phase. In the case of the test phase the bound goal is surefire's test mojo. So you could call

mvn surefire:test

,将不执行其他生命周期阶段. 您可以根据包类型这里.

and no other lifecycle phase will be executed. You can find the goals bound to each phase depending on the package type here.

这篇关于如何自动运行mvn测试(无需重建源代码)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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