简体   繁体   English

多模块gradle项目 - 执行所有单元测试

[英]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.

相关问题 使用单个命令从多模块项目运行所有 UI/单元测试 - Run all UI/Unit tests from a multi-module project using a single command 更新到android gradle插件2.3后,多模块MultiDex项目不会运行测试 - Multi-module MultiDex project won't run tests after update to android gradle plugin 2.3 多模块Android项目中的全局代码覆盖率:合并代码覆盖率报告(单元和UI测试) - Global code coverage in multi-module Android project: merge code coverage reports (Unit & UI tests) Intellij IDEA 13.1.13中具有Android + Gradle的多模块项目 - Multi-module project in Intellij IDEA 13.1.13 with Android+Gradle 如何在Gradle多模块项目中使用ObjectBox? - How to use ObjectBox in Gradle multi-module project? 使用 gradle DSL 在多模块项目中声明风味依赖项 - Declaring flavor dependencies in multi-module project using gradle DSL Gradle api与多模块项目实施的最佳实践 - Best practice for Gradle api vs implementation in multi-module project 具有多模块android库的Gradle配置 - Gradle configuration with multi-module android library Gradle多模块依赖问题 - Gradle multi-module dependecy issue Resources$NotFoundException 与多模块 Compose 测试 - Resources$NotFoundException with multi-module Compose tests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM