Hi! I have an Android project where `testDebugUnit...
# community-support
r
Hi! I have an Android project where
testDebugUnitTest
is not running unit tests in most of our application modules, i.e.
com.android.application
ones. It happily runs them in all the library modules, and curiously, one sample app module. More specific tasks like
testMyProductVariantDebugUnitTest
do run them. What can I look at (logs etc) to understand why this is happening?
e
better ask #CJYS1DAP5 or in an Android community but it depends on how your build variants are set up, that's expected
r
> it depends on how your build variants are set up, that's expected Can you expand on this please?
e
your app module doesn't have an "testDebugUnitTest", because only variants "test${Variant}DebugUnitTest" for various variants exists
✔️ 1
your library modules, without flavor dimensions, are different
r
Hmm. Thank you for this. So, the rationale makes sense. But if I iterate through the variants, I find that in their properties,
unitTestEnabled
is already true. So enabling it (and I have) doesn't do anything different. I suppose the answer might be a classic 'dependsOn' relationship?
e
no, I mean that you should use the existing lifecycle task "test"
it may run even more tests than you want, but then you can filter it down with that property
r
Oh, you're saying run
test
rather than
testDebugUnitTest
and then disable a bunch of stuff via
enableUnitTest = false
?
e
yes
the underlying test tasks are named differently in your different projects depending on the project configuration
r
Yeah, that makes a lot of sense, cheers. I suppose we historically ran the 'debug' task version to avoid pointlessly running the test suite again for all modules'
release
variants, but I don't know if that does actually happen or not, and similarly to avoid repetition for all product variants which as you say we could easily prevent in one coherent place.