Skip to content

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

@quittle

Description

@quittle

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions