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

Add hooks for pre- and post- test run execution #196

Open
quittle opened this issue Aug 27, 2022 · 0 comments
Open

Add hooks for pre- and post- test run execution #196

quittle opened this issue Aug 27, 2022 · 0 comments

Comments

@quittle
Copy link
Owner

quittle commented Aug 27, 2022

Similar to issue #193, it would be good if users had a straightforward way of running arbitrary code before and after the test run, but while the emulator is running and in a healthy state.

Additional feature considerations

  • Exposing adb binary location or command execution helpers

Example

This is not a proposal for implementation but suggests one way this could look to consumers

androidEmulator {
    onBeforeTestRun {
        // adb is a function defined in the scope of these
        adb("push", file(project.projectDir, "scripts/instrumentation-test-setup.sh"), "/sdcard/setup.sh")
        adb "shell", "bash /sdcard/setup.sh"
    }

    onAfterTestRun {
        // Any arbitrary code could be run

        // Retrieve files generated by the tests
        adb "pull", "/sdcard/test_output.json", file(project.buildDir, "test_output.json")

        result = adb "logcat", "-d"
        project.logger.debug("logcat stdout: " + result.stdout)
        project.logger.debug("logcat stderr: " + result.stderr)
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant