自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
开始使用 TF
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Trade Federation 是一个大型测试架构,可通过调整来适应各种不同的用途,大多数人可能只需要使用它的部分功能。首先,我们设想 TF 用户主要担任三种角色:开发者、集成者和测试运行者。某个特定人员可能担任其中一种或全部三种角色,但我们认为,按照三种不同角色的区分来浏览文档可能会更轻松。
开发者
开发者的主要工作是创建使用 Java 语言编写的 TF 模块。
他们还会编写配置并执行测试,但这样做通常是为了验证他们的模块是否可以正确调用并按预期效果运行。
集成者
集成者的主要工作是创建 XML 测试配置或命令文件(使用类似 shell 的简单语言编写)。他们将开发者编写的 TF 模块与特定测试要求和目标所需的特定配置相结合。
测试运行者
测试运行者的主要工作是执行测试,确保生成测试结果,并且生成的测试结果具有相关性、可重现性,而且是准确无误的。他们把大部分时间用于与 tradefed 的命令行界面进行交互,并且还将验证结果是否合理。
为了充分利用 Trade Federation,三种角色都需要有人担任,缺一不可。
开发者和集成者共同协作,来实现 TF 与基础架构的其他部分(如构建系统和测试结果存储库)的交互。集成者和测试运行者共同协作,确保 TF 能实际运行所需的测试,并产生所需的测试结果。测试运行者则需要识别出无意义的结果,并与开发者和集成者协作来找出存在 bug 的地方,并将其修复。
后续说明
担任这三种角色的人员至少应该浏览一下剩下的所有文档。
机器设置介绍了如何搭建 TF 运行环境(您可以构建此环境,也可以下载)。
使用设备介绍了如何使用物理设备、模拟器或不借助设备来运行测试。测试生命周期页面从理论角度说明了开发者、集成者和测试运行者这几种角色如何互动。选项处理则演示如何将该理论付诸实践。
最后,端到端示例会逐步介绍样本测试的开发、集成和部署过程。它涵盖了每个角色的各个方面,并提供了一些提示,指导您处理文档中未直接讨论的更复杂事项。
如果您已经阅读了本文档的所有内容,但仍有疑问,请先查阅 Trade Federation 源代码。此外,您还可以随时在 android-platform Google 群组中提问。为获得最佳解答,请务必在消息主题中提及“Trade Federation”(或“tradefed”/“TF”)。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Get started with TF\n\nTrade Federation is a large test infrastructure that can be adapted to a great variety of\ndifferent usecases, and most people will probably only need some subset of its functionality. First\noff, we envision that TF users will fulfill any of three primary roles: Developer, Integrator, and\nTest Runner. A particular individual might wear any (or all) of those three hats, but we feel the\ndistinction will help make it easier to navigate the documentation.\n\nDevelopers\n----------\n\nDevelopers spend the majority of their time creating TF modules that are written in Java.\nThey may write configurations and execute tests, but will typically only do so to verify that their\nmodules are being invoked properly and are functioning as expected.\n\nIntegrators\n-----------\n\nIntegrators spend the majority of their time creating XML test configurations, or command\nfiles (which are written in a simple shell-like language). They tie together TF modules written\nby the Developer with specific configurations that are required for particular test requirements and\ngoals.\n\nTest Runners\n------------\n\nTest Runners spend the majority of their time executing tests and generally making sure\nthat test results are being generated, and that the generated test results are relevant,\nreproducible, and accurate. They spend the majority of their time interacting with tradefed's\ncommand line interface, and will also verify that the results make sense.\n\nIn order to get the most out of Trade Federation, all three roles will need to be represented.\nIt will take Developers and Integrators to make TF interoperate with other pieces of infrastructure,\nlike build systems and test result repositories. It will take Integrators and Test Runners to get\nTF to actually run the desired tests and produce the desired test results. It will take Test\nRunners to identify results that don't make sense, and to work with the Developers and\nIntegrators to figure out where the bugs may lie and get them fixed.\n\nWhat's next\n-----------\n\nPeople in all three roles should at least glance through all the rest of the docs.\n[Machine Setup](/docs/core/tests/tradefed/fundamentals/machine_setup) will get you to the point where you can run TF (by building or downloading it).\n[Working with Devices](/docs/core/tests/tradefed/fundamentals/devices) will explain how to run tests with a physical device, with an emulator, or\nwith no device at all. The\n[Test Lifecycle](/docs/core/tests/tradefed/fundamentals/lifecycle) page will explain from a theoretical perspective how the roles of the\nDeveloper, Integrator, and Test Runner interact, and then\n[Option Handling](/docs/core/tests/tradefed/fundamentals/options) will demonstrate how to put that theory into practice.\n\nFinally, the [End-to-End Example](/docs/core/tests/tradefed/fundamentals/full_example) takes you through the development, integration, and deployment of a sample\ntest. It involves aspects of each role, and should offer hints at how to do more complicated\nthings that aren't directly discussed in the documentation.\n\nIf you've gotten through everything here and still have unanswered questions, first try taking\na look at the [Trade Federation source code](https://android.googlesource.com/platform/tools/tradefederation/+/main). Beyond that, feel free to try asking on the\n[android-platform](/docs/setup/community) Google Group. For best results, make\nsure to mention \"Trade Federation\" (or \"tradefed\", or \"TF\") in the message subject."]]