Java Maven-在模块中运行JUnit Testsuite
我有3个项目:Java Maven-在模块中运行JUnit Testsuite,java,unit-testing,maven,junit4,Java,Unit Testing,Maven,Junit4,我有3个项目: ParentProj(A+B的父级) ProjA(是ParentProj的一个模块,包含源代码) ProjB(是ParentProj的一个模块,包含源代码和测试) 建造顺序为:1。家长项目,2。ProjA,3。项目接线盒(无法更改!) 我想告诉maven执行位于ProjB中的TestSuite。 如果我使用以下命令运行构建:mvn clean-e test-Dtest=AllServiceTests,构建将失败,因为maven在ProjA中找不到“AllServiceTest
- ParentProj(A+B的父级)
- ProjA(是ParentProj的一个模块,包含源代码)
- ProjB(是ParentProj的一个模块,包含源代码和测试)
mvn clean-e test-Dtest=AllServiceTests
,构建将失败,因为maven在ProjA中找不到“AllServiceTests”类,它是在ProjB之前构建的
这个问题有什么解决办法吗?(更改构建顺序不是解决方案)最简单的解决方案是更改到ProjB目录并在那里执行命令行。您是否查看了
--还生成和--项目选项
$ mvn --help
usage: mvn [options] [<goal(s)>] [<phase(s)>]
Options:
-am,--also-make If project list is specified, also
build projects required by the
list
-pl,--projects <arg> Comma-delimited list of specified
reactor projects to build instead
of all projects. A project can be
specified by [groupId]:artifactId
or by its relative path.
请发回,让我们知道这是否有效!我真的很好奇 我刚刚找到了解决方案:
clean install test -Dtest=myTestSuite -DfailIfNoTests=false
-DfailIfNoTests=false
将强制maven在ProjA不包含测试类的情况下继续构建
这最终解决了我的问题。好吧,这不是解决方案,因为这个小构建是在竹服务器上完成的,而不是在我的本地命令行上;-)
clean install test -Dtest=myTestSuite -DfailIfNoTests=false