开发者

Maven - Run JUnit Testsuite in module

开发者 https://www.devze.com 2023-02-22 04:33 出处:网络
I have 3 Projects: ParentProj (parent of A+B) ProjA (is a module of ParentProj, contains sources) ProjB (is a modu开发者_运维百科le of ParentProj, contains sources and tests)

I have 3 Projects:

  • ParentProj (parent of A+B)
  • ProjA (is a module of ParentProj, contains sources)
  • ProjB (is a modu开发者_运维百科le of ParentProj, contains sources and tests)

Build order is: 1. ParentProj, 2. ProjA, 3. ProjB (could not be changed!)

I want to tell maven to execute a TestSuite that is located in ProjB. If I run the build with this command: mvn clean -e test -Dtest=AllServiceTests, the build will fail because maven could not find the "AllServiceTests"-class in ProjA, which is build before ProjB.

Is there any solution for this problem? (Changing the build order is no solution)


I just found the solution:

clean install test -Dtest=myTestSuite -DfailIfNoTests=false 

-DfailIfNoTests=false will force maven to continue with the build if ProjA contains no Test classes.

That finally fixed my problem.


Have you looked into the --also-make and --projects options?

$ 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.

Then I suppose this might work:

mvn clean test -pl ProjB -am -Dtest=AllServiceTests

Please post back and let us know if that works! I'm really curious. :)


The simpliest solution is to change to the ProjB directory and execute your command line there.

0

精彩评论

暂无评论...
验证码 换一张
取 消