https://github.com/testingbot/testingbot-gradle-plugin
Gradle plugin for TestingBot
https://github.com/testingbot/testingbot-gradle-plugin
gradle kotlin-android testingbot
Last synced: 3 days ago
JSON representation
Gradle plugin for TestingBot
- Host: GitHub
- URL: https://github.com/testingbot/testingbot-gradle-plugin
- Owner: testingbot
- License: mit
- Created: 2026-07-01T06:16:42.000Z (6 days ago)
- Default Branch: main
- Last Pushed: 2026-07-01T08:50:12.000Z (6 days ago)
- Last Synced: 2026-07-01T09:21:16.277Z (6 days ago)
- Topics: gradle, kotlin-android, testingbot
- Language: Kotlin
- Homepage: https://testingbot.com/support/app-automate/espresso
- Size: 117 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# TestingBot Gradle Plugin
[](https://github.com/testingbot/testingbot-gradle-plugin/actions/workflows/build.yml)
[](https://plugins.gradle.org/plugin/com.testingbot.gradle)
[](LICENSE)
A [Gradle](https://gradle.org/) plugin that uploads Android apps to
[TestingBot](https://testingbot.com) Storage and runs **Espresso** tests on TestingBot's
real device cloud — straight from your build, no `curl` scripts required.
## Features
- **`testingbotUpload`** — upload an APK to TestingBot Storage and get a reusable
`tb://` identifier.
- **`testingbotEspresso`** — upload your app + instrumented test APK, run Espresso across
one or more devices, wait for results, download a JUnit XML report, and fail the build on
test failures.
- **`testingbotDevices`** — list the Android devices available on your account.
- Credentials from the DSL, Gradle properties, or environment variables.
- Optional Android Gradle Plugin auto-wiring (build + test in one command).
- Zero extra HTTP dependencies on your build classpath; configuration-cache compatible.
## Requirements
- Gradle 8.0+ running on JDK 17 or newer.
- A TestingBot account. Grab your **key** and **secret** at
.
## Installation
```kotlin
// build.gradle.kts (your Android app module)
plugins {
id("com.testingbot.gradle") version "0.1.0"
}
```
Groovy DSL
```groovy
// build.gradle
plugins {
id 'com.testingbot.gradle' version '0.1.0'
}
```
## Credentials
Resolved in this order (first match wins):
1. The DSL — `testingbot { key.set("…"); secret.set("…") }`
2. Gradle properties — `-Ptestingbot.key=… -Ptestingbot.secret=…` (or in `gradle.properties`)
3. Environment variables — `TESTINGBOT_KEY` / `TESTINGBOT_SECRET`
In CI, prefer environment variables backed by secrets. **Never commit credentials.**
## Usage
```kotlin
testingbot {
// Credentials (optional here if provided via env vars / gradle properties)
key.set(providers.environmentVariable("TESTINGBOT_KEY"))
secret.set(providers.environmentVariable("TESTINGBOT_SECRET"))
// The app + instrumented test APKs
appApk.set(layout.projectDirectory.file("app/build/outputs/apk/debug/app-debug.apk"))
testApk.set(
layout.projectDirectory.file("app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk")
)
// One run is started per capability. Keys are passed through to TestingBot verbatim.
capabilities.set(
listOf(
mapOf("deviceName" to "Pixel.*", "version" to "14", "platformName" to "Android", "realDevice" to true),
mapOf("deviceName" to "Galaxy S.*", "version" to "13", "platformName" to "Android"),
)
)
// Optional behavior
waitForResults.set(true) // poll until the run completes (default true)
failBuildOnTestFailure.set(true) // default true
reportXml.set(layout.buildDirectory.file("testingbot/espresso-junit.xml"))
}
```
Then:
```bash
# Upload only
./gradlew testingbotUpload
# Build the APKs first, then run Espresso on TestingBot
./gradlew assembleDebug assembleDebugAndroidTest testingbotEspresso
# Discover device names/versions for your capabilities
./gradlew testingbotDevices
```
### Device capabilities
`deviceName` accepts a regular expression, so `"Pixel.*"` matches any Pixel and `"*"` any
device. Commonly used keys: `deviceName`, `version`, `platformName` (`"Android"`),
`realDevice`, `phoneOnly`, `tabletOnly`. Run `./gradlew testingbotDevices` to see what's
available on your plan.
### Optional: Android Gradle Plugin auto-wiring
If the `com.android.application` plugin is applied, naming a variant lets the plugin fill in
the conventional APK paths and depend on the matching `assemble` tasks automatically:
```kotlin
testingbot {
autoWireFromVariant.set("debug") // defaults appApk/testApk + dependsOn assembleDebug(AndroidTest)
capabilities.set(listOf(mapOf("deviceName" to "Pixel.*", "version" to "14", "platformName" to "Android")))
}
```
Now `./gradlew testingbotEspresso` builds the APKs and runs the tests in one go. Explicitly
set `appApk`/`testApk` paths always take precedence.
## Full DSL reference
| Property | Type | Default | Description |
|---|---|---|---|
| `key` | `String` | `TESTINGBOT_KEY` / `testingbot.key` | API key |
| `secret` | `String` | `TESTINGBOT_SECRET` / `testingbot.secret` | API secret |
| `apiBaseUrl` | `String` | `https://api.testingbot.com/v1` | API base URL |
| `appApk` | `RegularFile` | — | App APK to upload / test |
| `testApk` | `RegularFile` | — | Instrumented Espresso test APK |
| `capabilities` | `List>` | `[]` | One run per entry; passed through verbatim |
| `espressoOptions` | `Map` | `{}` | Optional run options passed through verbatim |
| `waitForResults` | `Boolean` | `true` | Poll until the run completes |
| `pollIntervalSeconds` | `Long` | `15` | Seconds between status polls |
| `timeoutMinutes` | `Long` | `30` | Max minutes to wait for results |
| `failBuildOnTestFailure` | `Boolean` | `true` | Fail the build when a run reports failures |
| `reportXml` | `RegularFile` | `build/testingbot/espresso-junit.xml` | Where to write the JUnit report |
| `autoWireFromVariant` | `String` | — | Optional AGP variant to auto-wire |
## CI example (GitHub Actions)
```yaml
- uses: actions/setup-java@v4
with: { distribution: temurin, java-version: 21 }
- run: ./gradlew assembleDebug assembleDebugAndroidTest testingbotEspresso
env:
TESTINGBOT_KEY: ${{ secrets.TESTINGBOT_KEY }}
TESTINGBOT_SECRET: ${{ secrets.TESTINGBOT_SECRET }}
```
The JUnit report written to `reportXml` can be published with your CI's test-report tooling.
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md). Security issues: see [SECURITY.md](SECURITY.md).
## License
[MIT](LICENSE) © TestingBot