gradle-plugin-robospock icon indicating copy to clipboard operation
gradle-plugin-robospock copied to clipboard

How to test flavours

Open pjakubczyk opened this issue 10 years ago • 3 comments

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.

pjakubczyk avatar Nov 24 '14 16:11 pjakubczyk

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!

Centril avatar Nov 24 '14 16:11 Centril

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.

Centril avatar Nov 26 '14 03:11 Centril

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.

bluesliverx avatar Dec 26 '14 18:12 bluesliverx