gradle-plugin-robospock
gradle-plugin-robospock copied to clipboard
How to test flavours
Could you please clarify how I can test project with flavors?
android { productFlavors {
f1 {
}
f2 {
}
}
}
then buildType = "f1Debug" ?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I was thinking on adding this feature, it is not implemented yet... If you want to have a go at it I'd gladly accept a pull-request!
My thinking is this:
We already know what product flavors are defined - so we can simply create one for each product flavor by default and then you can explicitly exclude the ones you don't want to test, or simply not provide any tests for them...
The sourcesets
would then become: tester.sourceSets.test{flavor}
, which would for example give you: tester.sourceSets.testF1
, tester.sourceSets.testF2
from your example which translates into: app-test/src/testF1/...
, app-test/src/testF2/...
. And we would of course add the main source set to the flavors...
The robospock
task will now execute all tests for all flavors... and robospock{flavor}
executes for that specific flavor, and robospockDefault
executes only the defaultConfig/main
tests.
More or less we have a source set for every build variant... including multi flavor stuff...
In this idea buildType
still only determines debug/release, and not flavors. I really don't see the point of being able to test debug & release separately, do you?
This would be similar to how the android plugin handles it.
Thoughts? If you like the idea I'll try to implement it.
For me, I don't care about testing flavors separately since they share the same code base and these are unit tests. I can't speak for other use cases, however, and what you suggested should work fine for what I need.