Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run adbserver-desktop.jar automatically during instrumentation tests #247

Open
ultraon opened this issue May 28, 2021 · 3 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@ultraon
Copy link

ultraon commented May 28, 2021

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?

@ultraon
Copy link
Author

ultraon commented May 28, 2021

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 :-(

@matzuk
Copy link
Member

matzuk commented Jun 4, 2021

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 =)

@AzamatCherchesov
Copy link
Collaborator

AzamatCherchesov commented Nov 11, 2022

We find this feature useful.

Requirements:

  1. Create a new module at the root of the Kaspresso project and place all new code and plugin there.
  2. Rewrite Kaspresso samples modules on a separate project to integrate the new plugin into existing tests
  3. Rename allure-support and compose-support modules to match their maven names.
  4. The new feature should be optional and easy to integrate (just by applying a plugin).
  5. 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
  6. In a negative scenario, there should be understandable error log information.
  7. 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
  8. All existing tests in the Kaspresso samples must use the new approach and be green.
  9. Add a new page to our Kaspresso github wiki with details on how to use the new feature and how it works.
  10. The supported version of Gradle + AGP - 7+

@AzamatCherchesov AzamatCherchesov added the enhancement New feature or request label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants