Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

Each of the modules contains features, one of the modules is the main module which builds the Android app by merging all required modules.

Each of the modules contains a lot of unit tests, and I'd like to execute them all in one gradle step. 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).

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.

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.

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.

like image 990
damian Avatar asked Feb 13 '18 10:02

damian


Video Answer


1 Answers

You can override the test method in your main module's build.gradle to only run the one time

like image 51
Yuxal Avatar answered Sep 27 '22 19:09

Yuxal