使用 Flutter 进行集成测试
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需使用 Firebase Test Lab 测试 Flutter 应用,您可以编写 Flutter 集成测试,构建 Android APK 或 iOS 测试 ZIP 文件,并以常规 Android 插桩测试或 iOS XCTest 的形式运行。
Flutter 集成测试类型
Flutter 支持三种类型的测试:单元测试、微件测试和集成测试。“单元测试”用于验证方法或类的行为。“微件测试”用于验证 Flutter 微件的行为,而不必运行应用本身。“集成测试”(也称为端到端测试或 GUI 测试)会运行完整的应用。
如需详细了解集成测试,请参阅 Flutter 集成测试。
编写 Flutter 集成测试
如需了解如何编写集成测试,请参阅 Flutter 集成测试文档的项目设置部分。(可选)您可以按照使用 Flutter 命令运行中的说明操作,在本地运行和验证测试。
在 Test Lab 中进行测试
您可以将 Test Lab 与 Android 和 iOS 目标结合使用。
Android 设置
按照 README 的 Android 设备测试部分中的说明操作。
iOS 设置
按照 README 的 iOS 设备测试部分中的说明操作。
Robo 测试支持
Robo 测试本身不支持 Flutter。如需改进应用的抓取方式,请使用 Robo 脚本。这些脚本是一些测试,用于自动执行移动应用的手动质量检查任务,并有助于实现持续集成 (CI) 和发布前测试策略。
例如,如需以更精确和可靠的方式控制 Robo 行为,您可以将点击与 visionText 配合使用。
分析测试结果
您可以将 Flutter 集成测试作为 Android 插桩测试或 iOS XCTest 运行。如需分析集成测试的结果,请参阅针对 Android 和 iOS 的文档,具体视您的平台而定。
限制
无法获得单独一个测试用例的测试用时信息,这意味着单个测试用例的时长和视频数等功能无法按预期运行。
问题排查
如果您遇到问题,请查看集成测试的公开问题跟踪器。
如果您遇到集成测试框架引起的新问题,请按照创建实用的 bug 报告中的指南,在公开问题跟踪器中提交新问题。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-16。
[null,null,["最后更新时间 (UTC):2025-08-16。"],[],[],null,["\u003cbr /\u003e\n\nTo test Flutter apps with Firebase Test Lab, you can write Flutter\nintegration tests, build Android APKs or iOS test zip files, and run as\nregular Android instrumentation tests or iOS XCTests.\n\nFlutter integration test types\n\nFlutter supports three types of tests: unit tests, widget tests, and\nintegration tests. A *unit test* verifies the behavior of a method or class.\nA *widget test* verifies the behavior of Flutter widgets without running the\napp itself. An *integration test*, also called end-to-end testing or GUI\ntesting, runs the full app.\n\nTo learn more about integration tests, see [Flutter integration testing](https://docs.flutter.dev/testing/integration-tests).\n\nWrite Flutter integration tests\n\nTo learn how to write integration tests, see the [project setup](https://docs.flutter.dev/testing/integration-tests#project-setup)\nsection of the Flutter integration tests documentation. Optionally, you can\nfollow [running using Flutter command](https://docs.flutter.dev/testing/integration-tests#running-using-the-flutter-command)\nto run and verify the tests locally.\n\nTest on Test Lab\n\nYou can use Test Lab with both Android and iOS targets.\n\nAndroid setup\n\nFollow the instructions in the\n[Android Device Testing](https://github.com/flutter/flutter/tree/main/packages/integration_test#android-device-testing)\nsection of the README.\n\niOS setup\n\nFollow the instructions in the\n[iOS Device Testing](https://github.com/flutter/flutter/tree/main/packages/integration_test#ios-device-testing)\nsection of the README.\n\nRobo test support\n\n[Robo tests](/docs/test-lab/android/robo-ux-test) do not natively support\nFlutter. To improve crawling of your app, use [Robo scripts](/docs/test-lab/android/run-robo-scripts),\nwhich are tests that automate manual QA tasks for mobile apps, and enable\ncontinuous integration (CI) and pre-launch testing strategies.\nFor example, to control Robo behavior in a more precise and robust way, you can\nuse clicks with [visionText](/docs/test-lab/android/robo-scripts-reference#click).\n\nAnalyze test results\n\nYou can run Flutter integration tests as an Android instrumentation test or an\niOS XCTest. To analyze the result of an integration test, see the\ndocumentation for [Android](https://firebase.google.com/docs/test-lab/android/analyzing-results)\nand [iOS](https://firebase.google.com/docs/test-lab/ios/analyzing-results),\ndepending on your platform.\n\nLimitations\n\nTest timing information for individual test cases is not available, which means\nthat features like test case duration and videos for individual test cases\ndon't work as expected.\n\nTroubleshooting\n\nIf you encounter issues, check the [public issue tracker for integration tests](https://github.com/flutter/flutter/issues?q=is%3Aopen+is%3Aissue+label%3A%22f%3A+integration_test%22).\n\nIf you encounter a new issue caused by the integration test framework,\nfile a new issue in the public issue tracker following the guidance in\n[Creating useful bug reports](https://docs.flutter.dev/resources/bug-reports)."]]