[英]Multi-module gradle project - Executing all Unit tests
Our current set-up looks like this: One root-project with nine sub-modules, which are mixed between pure Java libraries and Android libraries. 我们当前的设置如下所示:一个带有九个子模块的根项目,它们混合在纯Java库和Android库之间。
Each of the modules contains features, one of the modules is the main
module which builds the Android app by merging all required modules. 每个模块都包含一些功能,其中一个模块是
main
模块,它通过合并所有必需的模块来构建Android应用程序。
Each of the modules contains a lot of unit tests, and I'd like to execute them all in one gradle step. 每个模块都包含很多单元测试,我想在一个gradle步骤中执行它们。 Right now I'm using
gradlew test
for this, but since (for example) the main
module has multiple product flavors
it is executing the unit tests in this module multiple times (for each flavor). 现在我正在使用
gradlew test
,但由于(例如) main
模块有多种product flavors
因此它会在此模块中多次执行单元测试(对于每种风格)。
Ideally, I'd like to only execute the main
module unit tests once, for a certain flavor and signing configuration, but since the testFlavorDebug
tasks are created while evaluating the project (as far as I know) I cannot define this before actually executing the evaluation. 理想情况下,我只想执行一次
main
模块单元测试,以获得某种风格和签名配置,但由于testFlavorDebug
任务是在评估项目时创建的(据我所知),我无法在实际执行之前定义它评价。
I've tried to find the tasks in afterEvaluate
blocks, I've tried to loop over all modules, different combinations and ways, but I can't seem to figure out how to properly set this up. 我试图在
afterEvaluate
块中找到任务,我试图遍历所有模块,不同的组合和方式,但我似乎无法弄清楚如何正确设置它。
I'd be glad if someone has some pointers or experience with a set-up like this and could help me out. 如果有人对这样的设置有一些指导或经验并且可以帮助我,我会很高兴。 If you require additional information, let me know and I'll supply them, but as far as the project set-up it's pretty straight forward in regards to the multi-module setting.
如果您需要其他信息,请告诉我,我会提供给他们,但就项目设置而言,它在多模块设置方面非常直接。
您可以覆盖主模块的build.gradle中的测试方法,只运行一次
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.