自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
测试开发工作流
使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。
如需将测试集成到平台连续测试服务,测试就应该符合本页面中的准则并遵循以下建议流程。
- 使用 Soong 构建系统以实现简单的测试配置。
- 使用 Test Mapping 直接在 Android 源代码树中创建提交前和提交后测试规则。
- 使用 Atest 在本地运行测试。
测试类型
支持的测试类型包括:
功能测试对测试用例进行通过或未通过测试的断言,而指标测试通常重复执行操作以收集时间指标。
采用标准化的输入/输出格式后,不再需要对每个测试进行自定义结果解析和后处理,并且通用自动化测试框架可用于符合惯例的所有测试。如需了解 Android 附带的连续测试框架,请参阅 Trade Federation 概览。
测试用例准则
通过连续测试服务执行的测试用例应该是封闭测试,也就是说,所有依赖项均已声明并与测试一起提供。如需了解此原则,请参阅 Google Testing Blog 网站上的“Hermetic Servers”一文。简而言之,封闭测试无需:
- 登录 Google 账号
- 配置连接(电话/Wi-Fi/蓝牙/NFC)
- 传入测试参数
- 由自动化测试框架对特定的测试用例执行设置或拆解
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Test development workflow\n\nTo integrate tests into a platform continuous testing service, they should meet\nthe guidelines on this page and follow this recommended flow.\n\n1. Use the [Soong build system](https://android.googlesource.com/platform/build/soong/) for [Simple Test Configuration](/docs/core/tests/development/blueprints).\n2. Employ [Test Mapping](/docs/core/tests/development/test-mapping) to create pre- and post-submit test rules directly in the Android source tree.\n3. Run tests locally using [Atest](/docs/core/tests/development/atest).\n\nTest types\n----------\n\nSupported test types are:\n\n- [Instrumentation tests](/docs/core/tests/development/instrumentation) support both functional and metrics tests. See [Test your app](https://developer.android.com/studio/test/) for general app testing guidance.\n- [GoogleTest](/docs/core/tests/development/gtest) (GTest) supports the following test types:\n - [Functional GTests](/docs/core/tests/development/gtest-func-e2e) using the [GTest](https://github.com/google/googletest) framework\n - [Metric tests](/docs/core/tests/development/metrics) using [`google-benchmark`](https://github.com/google/benchmark)\n- [JAR host tests](/docs/core/tests/development/jar) using JUnit\n\nFunctional tests make assertions of pass or fail on test cases, while metrics\ntests generally perform an action repeatedly to collect timing metrics.\n\nWith standardized input/output format, the need for customized result parsing\nand post-processing per test is eliminated, and generic test harnesses can be\nused for all tests that fit into the convention. See the [Trade Federation\nOverview](/docs/core/tests/tradefed) for the continuous test framework\nincluded with Android.\n\nTest case guidelines\n--------------------\n\nTest cases executed through the continuous testing service are expected to be\n**hermetic** , meaning that all dependencies are declared and provided with the\ntests. See [Hermetic Servers on the Google Testing\nBlog](https://testing.googleblog.com/2012/10/hermetic-servers.html)\nfor an understanding of this principle. In short, hermetic tests require **no**:\n\n- Google Account sign-in\n- Connectivity configured (telephony/Wi-Fi/Bluetooth/NFC)\n- Test parameters passed in\n- Setup or tear down performed by test harness for a specific test case"]]