为Maven反应器嵌套子模块运行JUnit测试 [英] Run JUnit tests for Maven reactor nested sub-sub-module

查看:182
本文介绍了为Maven反应器嵌套子模块运行JUnit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用深层嵌套的Maven反应堆项目:

  • root pom.xml指定模块dspace
  • 模块dspacepom.xml指定模块modules
  • 模块modulespom.xml指定(其中包括)模块rest

因此有一个嵌套的模块层次结构:dspace -> modules -> rest.

我已经为(子-子)模块rest编写了JUnit测试,并希望执行它们.如果我运行mvn test -pl rest,则Maven失败:

[INFO] Scanning for projects...
[ERROR] [ERROR] Could not find the selected project in the reactor: rest @
[ERROR] Could not find the selected project in the reactor: rest -> [Help 1]

如何在嵌套的Maven模块中执行测试?

解决方案

非常简单:mvn test -pl dspace/modules/rest

(或默认情况下禁用测试的情况,例如DSpace Maven项目示例:mvn -Dmaven.test.skip=false test -pl dspace/modules/rest)

I'm working with a deeply nested Maven reactor project:

  • root pom.xml specifies a module dspace
  • module dspace's pom.xml specifies a module modules
  • module modules's pom.xml specifies (among others) a module rest

So there is a nested module hierarchy: dspace -> modules -> rest.

I have written JUnit tests for (sub-sub-)module rest and would like to execute them. If I run mvn test -pl rest, Maven fails:

[INFO] Scanning for projects...
[ERROR] [ERROR] Could not find the selected project in the reactor: rest @
[ERROR] Could not find the selected project in the reactor: rest -> [Help 1]

How can I execute tests in nested Maven modules?

解决方案

Pretty easy: mvn test -pl dspace/modules/rest

(or when tests are deactivated by default, as it is the case with the example DSpace Maven project: mvn -Dmaven.test.skip=false test -pl dspace/modules/rest )

这篇关于为Maven反应器嵌套子模块运行JUnit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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