Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit test configuration for multiple modules

Tags:

In Android Studio, it's pretty easy to create a configuration which runs the unit tests for a particular module. But is there a way to create a configuration which runs the unit tests for all modules?

My particular project has multiple modules (a "main" module and a "library" module, say). I currently have two configurations: Main Unit Tests and Library Unit Tests. This works, but it'd be nice to just have Unit Tests run all my tests.

From the command line, this is trivial - just run ./gradlew testDebug and everything's happy. But I can't seem to figure it out from Android Studio. What am I missing here?

Edit: cricket-007 points out that the gradle command bar in Android Studio can let you run the testDebug command. This works, but isn't as full featured as a true configuration. So really, the question is how to create a configuration Unit Tests that runs all of the unit tests from all modules.

like image 849
tmtrademark Avatar asked Oct 05 '16 15:10

tmtrademark


People also ask

Can a unit test test multiple classes?

A test can exercise methods from three objects and still be a unit test. Some may claim that's integration but three lines of code are just as "integrated" so that's not really a thing. Method and object boundaries don't present any significant barrier to testing.

Do you need a unit test for every method?

Every behavior should be covered by a unit test, but every method doesn't need its own unit test. Many developers don't test get and set methods, because a method that does nothing but get or set an attribute value is so simple that it is considered immune to failure.


1 Answers

I've been able to make it work choosing "All in package" and search for tests across module dependencies. Because my App module dependes from all other modules, all the tests are run when running this Task.

Configuration that worked for me

like image 192
DanielDiSu Avatar answered Sep 17 '22 17:09

DanielDiSu