---
title: 安卓Espresso云端自动化
description: 用Android Espresso加速你的测试，并在Android模拟器或TestingBot的真实设备上执行测试。
source_url:
  html: https://zh.testingbot.com/features/automation/espresso
  md: https://zh.testingbot.com/features/automation/espresso/index.md
---
浓缩咖啡云 
# 在真正的安卓设备上运行 Espresso

只需一条 CLI 命令，即可在 Android 4.4 至 Android 15 的真实 Galaxy、Pixel、OnePlus 和小米设备上运行 Espresso 套件。支持大规模并行处理、视频和日志记录，以及 99.99% 的正常运行时间 SLA。

想了解所有平台？请查看[完整的自动化框架阵容](https://zh.testingbot.com/features)。

[免费开始](https://zh.testingbot.com/users/sign_up)[申请演示](https://testingbot.com/demo)

真正的安卓设备200+

安卓版本4.4 → 15

正常运行时间服务级别协议99.99%

testingbot·espresso
     api.testingbot.com 

    # Install the TestingBot CLI$npminstall -gtestingbot-cli# Run Espresso on a real Android device in the cloud$testingbotespressoapp.apk app-test.apk \
        --device"Pixel 8"\
        --platform-version"14"\
        --real-device› uploading app.apk …✓› running on Pixel 8, Android 14 …✓› fetching results, video & logs …✓

     Galaxy · Pixel · OnePlus · Xiaomi parallel:10 ✓ tests passed 

 ![Pixel 8](https://zh.testingbot.com/assets/environments/svg/android-1b3d235e17522e2238e1c55b4e9cdd41219f653cd958ea065877d3813f32ffc3.svg)Pixel 8

 ![Galaxy S24](https://zh.testingbot.com/assets/environments/svg/android-1b3d235e17522e2238e1c55b4e9cdd41219f653cd958ea065877d3813f32ffc3.svg)Galaxy S24

 ![OnePlus 12](https://zh.testingbot.com/assets/environments/svg/android-1b3d235e17522e2238e1c55b4e9cdd41219f653cd958ea065877d3813f32ffc3.svg)OnePlus 12

被世界上一些最具创新性的公司所信任

 30秒回答 
## 为什么要在 TestingBot 上运行 Espresso？

  真正的安卓设备

支持在真实的 Galaxy、Pixel、OnePlus 和小米设备上运行，而非仅限于模拟器。首发支持最新旗舰机型，同时还支持从 Android 4.4 开始的众多经典机型。

  替换您内部的安卓实验室

无需面对布满灰尘的手机柜、鼓包的电池和厂商无休止的系统更新。TestingBot 已在真实设备上进行 Android 测试超过 5 年。

  原生 Java 和 Kotlin

使用 Google 为 Android Studio 提供的 Espresso 框架。相同的 API，相同的 JUnit 断言，真正的原生性能。

 什么是意式浓缩咖啡？ 
## 60秒内制作一杯意式浓缩咖啡

 ![Espresso](https://zh.testingbot.com/assets/environments/svg/android-1b3d235e17522e2238e1c55b4e9cdd41219f653cd958ea065877d3813f32ffc3.svg)

### Espresso

Google · built into Android Studio · Java / Kotlin

Espresso 是谷歌官方的 Android UI 测试框架，内置于 Android Studio 和 Android SDK 中。它使用 AndroidJUnitRunner 检测运行器，允许你针对应用的实际 UI 编写点击、滑动、滚动、意图和视图断言等脚本。

由于 Espresso 与应用运行在同一进程中，因此测试快速可靠，测试线程和 UI 线程之间会自动同步。它是快速、进程内 Android UI 测试的首选工具。

- Android Studio 内置的原生 Google 框架
- Java 和 Kotlin 绑定
- 真正的 Galaxy、Pixel、OnePlus、小米手机和模拟器
- 视图匹配器、视图操作、视图断言、意图
- AndroidJUnitRunner，用于 CI 的 JUnit XML 输出

 单行命令行界面 
## 使用一条命令即可在真实设备上运行 Espresso

安装 TestingBot CLI，将其指向您的应用 APK 和测试 APK，选择设备——完成！上传、功能获取和结果轮询等操作都由系统自动处理。

 ![](https://zh.testingbot.com/assets/environments/svg/android-1b3d235e17522e2238e1c55b4e9cdd41219f653cd958ea065877d3813f32ffc3.svg)install the CLIstep 1

    # Install the TestingBot CLI$npminstall -gtestingbot-cli# Authenticate (once) — set your KEY and SECRET$exportTESTINGBOT_KEY=your-key$exportTESTINGBOT_SECRET=your-secret# Build app + Espresso test APKs (one-off)$./gradlew assembleDebug \
        assembleDebugAndroidTest

 ![](https://zh.testingbot.com/assets/environments/svg/android-1b3d235e17522e2238e1c55b4e9cdd41219f653cd958ea065877d3813f32ffc3.svg)run Espressostep 2

    # Run Espresso on a real Pixel — one command$testingbotespressoapp.apk app-test.apk \
        --device"Pixel 8"\
        --platform-version"14"\
        --real-device# Or, on a Galaxy$testingbotespressoapp.apk app-test.apk \
        --device"Galaxy S24"\
        --real-device# → live results in your TestingBot dashboard# → JUnit XML, video and logcat via REST API

有关高级标志、并行运行和 CI 集成，请参阅[TestingBot 上的完整 Espresso 文档](https://testingbot.com/support/app-automate/espresso)。

 购买还是建造 
## TestingBot 与内部 Android 设备实验室的对比

自建安卓设备实验室成本高昂。设备容易损坏，OEM厂商自行决定更新计划，三星的Knox安全防护机制也经常变化。以下是托管式安卓设备云平台的对比。

| 能力 | 测试机器人 | 内部安卓实验室 |
| --- | --- | --- |
| 设备覆盖范围 | 
  Galaxy、Pixel、OnePlus、小米，Android 4.4 至 15
 | 
  仅限于你能购买和购买的商品。
 |
| 是时候进行首次测试了 | 
  几分钟，一条 CLI 命令，你就可以运行了
 | 
  数周的配置、ADB、MDM 和网络共享
 |
| 并行扩展 | 
  最多可同时进行 100 场 Espresso 会话
 | 
  受您拥有的设备数量限制。
 |
| 视频和日志 | 
  视频、logcat日志、屏幕截图和JUnit XML
 | 
  自行实现录制和日志聚合
 |
| 可靠性 | 
  99.99% 正常运行时间 SLA，全天候监控
 | 
  你会更换没电的电池和破损的屏幕。
 |
| 安全 | 
  每次会话之间设备都会被擦除
 | 
  手动清理，遗留状态风险
 |
| 支持 | 
  全天候人工支持和专属客户服务经理
 | 
  Stack Overflow 和您自己的日志
 |

 能力 
## Espresso 所需的一切云端功能

除了运行测试之外，TestingBot 还提供了你在 Android Studio 中设置的所有 Espresso 功能，以及仅限云端使用的功能，例如地理位置和网络限速。

- 
### [Instrumentation](https://testingbot.com/support/app-automate/espresso/instrumentation)

Configure AndroidJUnitRunner instrumentation arguments per run.

- 
### [Test filters](https://testingbot.com/support/app-automate/espresso/filter)

Run a subset of your Espresso suite without rebuilding the bundle.

- 
### [Test reports](https://testingbot.com/support/app-automate/espresso/test-reports)

Video, logcat, screenshots and JUnit XML for every run.

- 
### [Screenshots](https://testingbot.com/support/app-automate/espresso/screenshots)

Take in-test screenshots and pull them via the REST API.

- 
### [Network throttling](https://testingbot.com/support/app-automate/espresso/simulate-network-conditions)

Simulate 3G, 4G, lossy WiFi and offline conditions per session.

- 
### [Localization & geo](https://testingbot.com/support/app-automate/espresso/set-localization-options)

Set device locale, language and GPS coordinates for store-front and back-end checks.

  真正的安卓设备 
## Galaxy、Pixel、OnePlus 和小米手机按需购买

使用 Espresso 在 TestingBot 云平台上对真实的 Android 设备进行测试。TestingBot 提供从 Android 4.4 到 Android 15 的设备版本。

[查看所有设备](https://testingbot.com/support/app-automate/devices)

 ![Test online on Galaxy S26](https://zh.testingbot.com/assets/devices/160h/40-e917ed08e15b5941fed75855ac457dd1df46b471a2020f081c4d70cefb68f4e8.webp)

Galaxy S26

 ![Test online on Huawei P40](https://zh.testingbot.com/assets/devices/160h/39-32a788c7e66a3da1c88eaaefefd37381f729e510f096b43906968b6907c44c57.webp)

Huawei P40

 ![Test online on Pixel 10](https://zh.testingbot.com/assets/devices/160h/37-738ed465eff0a4bcc33a5294f6f9f4d701fed317ce0e97e202ffc3f9dca7edd4.webp)

Pixel 10

 ![Test online on Pixel 9](https://zh.testingbot.com/assets/devices/160h/35-abb9a661ebbfa84f18bd6985d3e80330ad43fe4ea7d408157c87ae0f560a5ca1.webp)

Pixel 9

 ![Test online on Galaxy S25](https://zh.testingbot.com/assets/devices/160h/34-ba3caa0fe8fb834ea684e524f6ad690ca4f78402e85a51a48e94ad4dfcb93208.webp)

Galaxy S25

 ![Test online on Redmi Note 13](https://zh.testingbot.com/assets/devices/160h/32-5f416c0f9e99cc3c6782b2b50072f406a8056e009850c16693dbc1fe815f88db.webp)

Redmi Note 13

 ![每次运行都会生成视频、屏幕截图和 JUnit XML 文件](https://zh.testingbot.com/assets/features/test-results-315382c39a67ad52167d2a4fd78570c99aea3e0ec386c17e82265851e93cb7b3.png)

  测试报告 
## 每次运行都会生成视频、屏幕截图和 JUnit XML 文件

每次 Espresso 运行都会附带视频屏幕录像、logcat 输出、视口截图和与所有主流 CI 解析器兼容的 JUnit XML 报告。

从测试中将会话标记为通过或失败，通过我们的[REST API](https://testingbot.com/support/api)获取工件，并将结果发送到 Jira、Slack 或您的 CI 仪表板。

- 每次测试运行均提供全高清视频
- logcat 输出、应用程序日志和崩溃报告
- 按需提供视口屏幕截图
- 适用于 Jenkins、GitHub Actions 和 GitLab CI 的 JUnit XML

 持续集成 
## 几分钟即可将 Espresso 连接到您的 CI/CD 系统

TestingBot 可与所有主流 CI/CD 工具集成。它会在每次构建时触发 Espresso，并将设备视频和 JUnit 报告流式传输到您的构建仪表板。

[ 
 ![Jenkins](https://zh.testingbot.com/assets/integrations/jenkins-e586a1c4af833e4c8d38d7b392a4e84bd193f30cae9cf8c9f198a58ec943a1ff.webp)
 
### Jenkins
 ](https://testingbot.com/support/integrations/ci-cd/jenkins)[ 
 ![Bamboo](https://zh.testingbot.com/assets/integrations/bamboo-c8fe09a3cb0b74d6055e3aa6607d77720bfe29ff487b8e3cf825138adf634346.svg)
 
### Bamboo
 ](https://testingbot.com/support/integrations/ci-cd/bamboo)[ 
 ![TeamCity](https://zh.testingbot.com/assets/integrations/teamcity-7e75cdb835903a4983ad276c41d95e569ceac5be486e96ec1f955029ce5bb319.svg)
 
### TeamCity
 ](https://testingbot.com/support/integrations/ci-cd/teamcity)[ 
 ![CircleCI](https://zh.testingbot.com/assets/integrations/circleci-ede029654ff39b60342e4a5bba8fc9a3a49305cc38bda215b7cf8d07e85e0543.webp)
 
### CircleCI
 ](https://testingbot.com/support/integrations/ci-cd/circleci)[ 
 ![GitLab CI](https://zh.testingbot.com/assets/integrations/gitlab-e4c0b6db07d07bc0a400f5606e258f4dc8a51b778e97bbfa51d1d531f3cb049a.webp)
 
### GitLab CI
 ](https://testingbot.com/support/integrations/ci-cd/gitlab)[ 
 ![GitHub](https://zh.testingbot.com/assets/integrations/github-actions-8436242ad9e15381f84f1a98a10dddce15611087f121d6305782e211942b7842.webp)
 
### GitHub
 ](https://testingbot.com/support/integrations/ci-cd/github-actions)

Spoof device GPS
20+ regions

🇺🇸美国

🇬🇧英国

🇩🇪德国

🇫🇷法国

🇪🇸西班牙

🇧🇪比利时

🇦🇺澳大利亚

🇨🇳中国

🇯🇵日本

  地理位置测试 
## 在 20 多个地区测试您的 Android 应用

将设备的 GPS 定位欺骗到世界任何地方，并从客户居住的任何国家/地区验证 **定位** 、 **地理定位** 和 **Play 商店店面规则** 。

  安全设备 
## 真实设备。每次使用后均会清除数据。

每次 Espresso 体验活动都会锁定一台真实的安卓设备供您专属测试。测试结束后，设备将被彻底清除数据，所有已安装的应用将被删除，缓存将被清除，设备将被放回设备池，供下一位顾客使用。

符合 SOC 2 标准和 GDPR 要求，并为企业团队提供 SAML SSO 和审计日志。

- 每次会话使用一台真实设备，绝不共享
- 每次会话之间都会清除数据
- 加密的 .apk 上传，并带有应用级保留控制

[访问 TestingBot 信任中心](https://trust.testingbot.com/)

1. 1

你的浓缩咖啡制作过程锁定了一个真正的设备

您将专属获得一部崭新的 Galaxy、Pixel、OnePlus 或 Xiaomi 手机。

2. 2

测试在真实的 Android 硬件上原生运行。

真正的传感器、真正的指纹识别器、真正的OEM定制。

3. 3

发布时设备数据已清除

应用已卸载，缓存已清除，账户已注销。已干净地重新投入使用。

 ![TestingBot secure tunnel for Espresso](https://zh.testingbot.com/assets/tunnel-diagram-5f56f4b5abdaac97336aed48dd92d9cb36acc72548052521f3581b18b88bd9ad.png)

  Secure Tunnel 
## 测试与内部后端通信的应用程序

使用我们的[安全隧道](https://testingbot.com/support/tunnel)，Espresso 运行可以访问私有 API、暂存环境以及在本地主机上运行的服务。

端到端加密，无需入站防火墙规则，开箱即用，适用于主流 CI 提供商。

[阅读更多](https://testingbot.com/support/tunnel)

常问问题
## TestingBot 上的 Espresso — 常见问题解答

Espresso是什么？为什么要在TestingBot上运行它？  

Espresso 是 Google 为 Android 开发的原生 UI 测试框架。TestingBot 会在一系列真实的 Galaxy、Pixel、OnePlus 和小米设备上运行您的 Espresso 构建版本，因此您无需自行维护设备、OEM 更新和 ADB 通道。只需通过 TestingBot CLI 上传您的`.apk`和`.apk`测试包，即可在几秒钟内触发测试运行。

支持哪些安卓版本？  

TestingBot 支持从 Android 4.4 到 Android 15 的真机，并会随着 Google 和 OEM 的每次版本更新而更新。我们涵盖最新的 Galaxy、Pixel 和 OnePlus 旗舰机型，以及丰富的旧款机型，确保向下兼容。

我可以在真机和模拟器上运行吗？  

是的。TestingBot 计划同时支持真实的 Android 设备和带有 Google Play API 的 Android 模拟器。您可以在 TestingBot 命令行界面中使用 `--real-device` 参数来切换是否支持单个测试。

我可以同时运行 Espresso 吗？  

是的。TestingBot 的计划包括在真机和模拟器上同时运行多达 100 个 Espresso 会话。每个会话都会锁定一台专用设备，因此测试之间不会相互干扰。

我可以筛选要运行的测试吗？  

是的——使用[测试过滤器 API](https://testingbot.com/support/app-automate/espresso/filter)来运行 Espresso 套件的子集，而无需重新构建软件包。

如何查看结果？  

在 TestingBot 控制面板中实时查看高清视频、logcat 输出和屏幕截图。可通过[REST API](https://testingbot.com/support/api)以编程方式进行操作。此外，还提供与所有主流 CI 解析器兼容的 JUnit XML 报告。

Espresso 能否访问我的测试后端？  

安装我们的[安全隧道](https://testingbot.com/support/tunnel)后，您的 Espresso 运行即可访问暂存 API、内部服务和本地主机，而无需任何入站防火墙规则。

该设备云是否符合 GDPR / SOC 2 标准？  

TestingBot 符合 GDPR 法规，拥有欧盟数据驻留权，并通过了 ISO 27001 认证和 STAR 1 级认证。设备在会话之间会被清除数据，应用程序上传经过加密，企业版套餐还提供 SAML 单点登录和审计日志功能。

## 准备好开始测试浓缩咖啡了吗？

要开始，请看我们的[Espresso测试](https://testingbot.com/support/app-automate/espresso)文件。

[开始免费试用](https://zh.testingbot.com/users/sign_up)

您可能喜欢的资源

[![Android Espresso Tutorial](https://zh.testingbot.com/assets/resources/articles/19-fe4971eb8049097c25f2cc2fce95b71b94f3bb342e094c219b2404c09374f015.webp)](https://testingbot.com/resources/articles/android-espresso-testing)
#### [Android Espresso Tutorial](https://testingbot.com/resources/articles/android-espresso-testing)

Learn more about Android Espresso Testing in this tutorial.

[阅读更多](https://testingbot.com/resources/articles/android-espresso-testing)
