简体   繁体   English

gradle:如何从根项目运行子项目的JUnit测试?

[英]gradle: How to run JUnit tests of a child project from the root project?

I have a root project called "myRootPrj" and several child projects (a EJB project, a UI project and so on). 我有一个名为“ myRootPrj”的根项目,还有几个子项目(EJB项目,UI项目等)。 The EJB project "myEJBPrj" contains also JUnit testcases (under myEJBPrj/src/test/java/... ). EJB项目“ myEJBPrj”还包含JUnit测试用例(在myEJBPrj/src/test/java/... )。

In the build.gradle of the "myRootPrj" I have add: 在“ myRootPrj”的build.gradle中,我添加了:

dependencies {
  ...
  testCompile project(':myEJBPrj')
}

But when I call the "test" task of the "myRootPrj" I get: 但是,当我调用“ myRootPrj”的“测试”任务时,我得到:

 Skipping task ':test' as it has no source files and no previous output files.

Seems that the "myRootPrj" don't find any test classes ... right? 似乎“ myRootPrj”没有找到任何测试类...对吗? Why that? 为什么?

2 things 2件事

First, about your question How to run JUnit tests of a child project from the root project? 首先,关于您的问题如何从根项目运行子项目的JUnit测试?

Just run gradle :myEJBPrj:test 只需运行gradle :myEJBPrj:test

Then, setting testCompile project(':myEJBPrj') in myRootPrj project means that this one will use myEJBPrj sources to compile myRootPrj test sources but you don't have any test sources in your root project to the test task is ignored. 然后,在myRootPrj项目中设置testCompile project(':myEJBPrj')意味着该项目将使用myEJBPrj源来编译myRootPrj测试源,但是您的根项目中没有任何测试源可以忽略该测试任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM