Issue
I've got this Android, with the default Gradle-tasks. In the Android-project, there is a androidTest
package, containing integrationTests
and uiTests
. I have also two Kotlin classes containing a suite of test classes to be called.
However, ./gradlew connectedAndroidTest
runs both integrationTests
and uiTests
, I want to separate this. I came up with multiple solutions:
- Android Studio's run configurations. However, this isn't checked into VCS, therefore we have no access on our Jenkins build server.
- Add Gradle tasks in the Groovy language, however, it's not encouraged to call another gradle task in a new task.
So I'm looking for a way to only test either integrationTests
or uiTests
. How can I do this?
Solution
I'm going to give you a cheap and cheerful answer now. Maybe someone else will be able to provide a fuller one.
Since all the tests appear to be part of the same source set, you need to distinguish between them some other way. The most appropriate solution is whatever mechanism your testing library has for grouping, which you can then utilise from Gradle.
Alternatively, use something like a naming convention to distinguish between UI tests and integration tests.
What you do then depends on how you want the build to deal with these different categories. The main options include:
Using test filtering from the command line — via the
--tests
option — to run just integration or UI tests. Note that filtering only works via class name, so you'd have to go with the naming convention approach.Configure the appropriate
Test
task — is thatconnectedAndroidTest
? — so that if you set a particular project property it will run either the integration tests or the UI tests based on the value of that project property. This involves using anif
condition in the configuration. This approach works with both filtering and grouping.Add two extra
Test
tasks, one that executes the integration tests and one that executes the UI tests. You would leaveconnectedAndroidTest
untouched. This is my preferred approach, but requires a bit more code than the others.
This answer is missing a lot of detail on how to implement those solutions, but I'm afraid filling that detail out is too time-consuming for me right now. As I said, hopefully someone will come along with a fuller answer.
Answered By - Peter Ledbrook
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.