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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With