是否有任何 Maven cmd 只能在没有整个项目的情况下构建测试?
Is there any Maven cmd that can only build test without the whole project?
我有一个大型服务器项目,以及一些使用 maven 的相关单元测试文件。
当我为某些 java 文件添加新的 UnitTest 时,我只想构建当前的 UnitTest 和 运行 它,我不想从初学者构建整个服务器项目.
但是当我使用:
mvn test -Dtest=NewUnitTest
我还需要等待很长时间才能构建整个服务器项目
有没有办法只构建新添加的单元测试文件?
谢谢。
你是怎么做到的?
如果你运行 清理然后编译它会删除所有内容然后编译。
如果你只是 运行 mvn test-compile 那么它应该只编译任何过时的东西,包括任何测试代码
尝试以下方法:
mvn compiler:testCompile surefire:test -Dtest=NewUnitTest
- compiler:testCompile - 将编译你的测试(如果你需要的话)
- surefire:test - 将执行您的测试
我假设你有多模块构建。只是 运行(从根开始):
mvn clean test -Dtest=NewUnitTest -pl :<the artifactId of the project you want to test>
显然,如果您尝试测试的项目依赖于反应器中的其他工件,并且无法从中央存储库获取它们,您可能也需要构建这些工件。只需添加 "also-make" 标志 (-am
):
mvn clean test -Dtest=NewUnitTest -pl :<the artifactId of the project you want to test> -am
我有一个大型服务器项目,以及一些使用 maven 的相关单元测试文件。
当我为某些 java 文件添加新的 UnitTest 时,我只想构建当前的 UnitTest 和 运行 它,我不想从初学者构建整个服务器项目.
但是当我使用:
mvn test -Dtest=NewUnitTest
我还需要等待很长时间才能构建整个服务器项目
有没有办法只构建新添加的单元测试文件?
谢谢。
你是怎么做到的?
如果你运行 清理然后编译它会删除所有内容然后编译。
如果你只是 运行 mvn test-compile 那么它应该只编译任何过时的东西,包括任何测试代码
尝试以下方法:
mvn compiler:testCompile surefire:test -Dtest=NewUnitTest
- compiler:testCompile - 将编译你的测试(如果你需要的话)
- surefire:test - 将执行您的测试
我假设你有多模块构建。只是 运行(从根开始):
mvn clean test -Dtest=NewUnitTest -pl :<the artifactId of the project you want to test>
显然,如果您尝试测试的项目依赖于反应器中的其他工件,并且无法从中央存储库获取它们,您可能也需要构建这些工件。只需添加 "also-make" 标志 (-am
):
mvn clean test -Dtest=NewUnitTest -pl :<the artifactId of the project you want to test> -am