Kaspresso
Kaspresso copied to clipboard
Run `adbserver-desktop.jar` automatically during instrumentation tests
Hello guys, I want to thank you for this amazing Framework!
And I want to suggest you providing an auto-run setup for adbserver-desktop.jar
.
In the appropriate a gradle module build.gradle
we need to add changes as follows:
plugins {
// ...
// https://github.com/hesch/gradle-execfork-plugin
id 'com.github.hesch.execfork' version '0.1.15'
}
android {
// ...
testVariants.all { variant ->
variant.connectedInstrumentTest.dependsOn tasks.named("startAdbDaemon")
}
}
/**
* It uses Gradle Plugin `com.github.hesch.execfork`
* The task starts automatically, it is connected to androidTest lifecycle using line
* `variant.connectedInstrumentTest.dependsOn tasks.named("startAdbDaemon")` above.
* And the task finishes as soon as build is finished.
*/
tasks.register("startAdbDaemon", com.github.psxpaul.task.ExecFork) {
executable = 'java'
args = [ '-jar', './bin/adbserver-desktop.jar' ]
workingDir = "$rootProject.rootDir"
}
And don't forget that adbserver-desktop.jar
should be placed by the path: <root_project>/bin/adbserver-desktop.jar
.
Do you think it worth having this sample in a Kaspresso doc?
One important note - it works only for a build that is started by using gradle task connectedAndroidTest
. By starting tests from AndroidStudio it doesn't work :-(
Hi @ultraon!
Sure, we thought about the simplifying of the AdbServer starting and how to make it as much transparent for a user as it is possible. But honestly, there is not a universal and simple solution here. The variant with Gradle is related to only connectedAndroidTest
.
I think that the execution of a jar file is easier than having a deal with Gradle, especially for beginners =)
We find this feature useful.
Requirements:
- Create a new module at the root of the Kaspresso project and place all new code and plugin there.
- Rewrite Kaspresso samples modules on a separate project to integrate the new plugin into existing tests
- Rename allure-support and compose-support modules to match their maven names.
- The new feature should be optional and easy to integrate (just by applying a plugin).
- The plugin needs to know the correct path to adb. There must be a config block with a string argument ADB_PATH. If this argument is not passed, the fallback source must be android plugin
- In a negative scenario, there should be understandable error log information.
- Often we need to pull/push some files from/to device. That is why adb server should receive working dir as a string argument. If this argument is not passed, the fallback source must be project's root
- All existing tests in the Kaspresso samples must use the new approach and be green.
- Add a new page to our Kaspresso github wiki with details on how to use the new feature and how it works.
- The supported version of Gradle + AGP - 7+