Firebase Test Lab 使用入门 (iOS)
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
利用 Firebase Test Lab,您可以在一系列设备上以及各种配置下测试您的应用。本指南简要介绍了 Test Lab 的关键概念、iOS 相关服务,以及有关如何开始测试的说明。
如需了解 Test Lab 配额和定价方案,请参阅用量、配额和价格。
主要概念和术语
当您针对所选的设备和配置运行一项测试或一组测试用例时,Test Lab 会批量为您的应用运行测试,然后将结果显示为一个测试矩阵。
设备 × 测试作业 = 测试矩阵
- 设备
- 运行测试的实体设备或虚拟设备(仅限 Android),例如手机、平板电脑或穿戴式设备。测试矩阵中的设备由设备型号、操作系统版本、屏幕方向和语言区域(也称为地理位置和语言设置)标识。
- 测试、测试作业
- 需要在设备上运行的一项测试(或一组测试用例)。您可以在每个设备上运行一项测试,也可以视需要对测试进行分片,并在不同的设备上运行其测试用例。
- 测试矩阵
- 测试矩阵中包含测试作业的状态和测试结果。只要矩阵中有任何测试作业失败,整个矩阵都会失败。
第 1 步:准备测试以便上传到 Test Lab
您可以使用 Test Lab 运行以下测试。请注意,不论测试类型如何,所有测试在实体设备上的运行时长上限都是 45 分钟,任何未捕获的异常都将导致测试失败。
XCTest(包括 XCUITest)测试:您使用 XCTest 框架编写的单元测试。如需了解如何修改 XCTest 测试以通过 Test Lab 运行此类测试,请参阅创建 XCTest 测试。
游戏循环测试:此类测试使用“演示模式”在游戏应用中模拟玩家操作。这是一种快速、可伸缩的方式,用于验证您的游戏是否能为用户提供优质体验。选择运行游戏循环测试时,您可以做到以下几点:
参阅运行游戏循环测试,了解如何在 Test Lab 中运行测试。
您可以选择使用以下工具运行测试:
借助 Firebase 控制台,您可以从任意位置上传应用并启动测试。有关使用此工具的说明,请参阅通过 Firebase 控制台进行测试。
借助 gcloud 命令行界面 (CLI),您可以使用命令行以交互方式运行测试,并且此命令行界面也非常适合以脚本方式在自动构建和测试流程中运行测试。如需了解如何使用此工具,请参阅通过 gcloud CLI 进行测试。
在实体设备上进行测试之前,请在模拟器上本地运行测试,以确保其按预期运行。如需查看相关说明,请参阅在本地测试。
第 3 步:指定测试设备
借助 Test Lab,您可以在托管于 Google 数据中心内的各种 iOS 设备和型号上测试您的应用。如需了解详情,请参阅可供使用的设备。
第 4 步:查阅测试结果
无论您通过何种方式发起测试,所有测试结果均由 Test Lab 管理,并且可供在线查看。
系统会自动存储测试结果摘要,您可以在 Firebase 控制台中查看这些摘要。其中包含与您的测试最为相关的数据,包括特定测试用例的视频、屏幕截图、通过的测试数量、失败的测试数量、结果不稳定的测试数量等。
原始测试结果包含测试日志和应用故障详情,这些信息会自动存储在 Google Cloud 存储桶中。如果您指定了一个存储桶,则需要支付相应的存储费用。如果您未指定存储桶,Test Lab 会为您免费创建一个。
如需了解详情,请参阅分析 Firebase Test Lab 结果。
设备清理
Google 非常重视您的应用数据的安全。我们遵循行业标准的最佳实践,每次测试运行完毕之后都会从实体设备中移除应用数据并重置这些实体设备的系统设置,确保其准备好运行新的测试。对于那些可以使用自定义恢复映像进行快速清理的设备,我们会多采取一个步骤,即在两次测试运行之间快速清理这些设备。
对于 Test Lab 所使用的虚拟设备,我们会在使用设备实例之后将其删除,这样每次测试运行都会使用一个新的虚拟设备实例。
允许 Test Lab 设备访问专用后端服务器
某些移动应用需要与专用后端服务通信,才能在测试期间正常运行。如果您的后端服务器受防火墙规则保护,您可以使用下方的 IP 地址段以通过防火墙打开路由,从而允许 Test Lab 的实体设备和虚拟设备访问后端服务器。
移动广告
Test Lab 提供了一个可伸缩的基础架构,可自动执行应用测试。遗憾的是,此功能可能会被旨在获取欺诈性广告收入的恶意应用滥用。
为了缓解这一问题:
Test Lab 设备使用的 IP 地址
Test Lab 设备生成的所有网络流量均源自以下 IP 地址段。您还可以使用 gcloud CLI 中的 gcloud beta firebase test ip-blocks list
命令访问此列表。该列表平均每年更新一次。
平台和设备类型 |
CIDR IP 地址段 |
Android 和 iOS 实体设备、Arm 虚拟设备 |
70.32.128.0/19(2022 年 2 月添加)
108.177.6.0/23
108.177.18.192/26(2022 年 2 月添加)
108.177.29.64/27(2022 年 2 月扩展)
108.177.31.160/27(2022 年 2 月添加)
199.36.156.8/29(2022 年 2 月添加)
199.36.156.16/28(2022 年 2 月添加)
209.85.131.0/27(2022 年 2 月添加)
2001:4860:1008::/48(2022 年 2 月添加)
2001:4860:1018::/48(2022 年 2 月添加)
2001:4860:1019::/48(2022 年 2 月添加)
2001:4860:1020::/48(2022 年 2 月添加)
2001:4860:1022::/48(2022 年 2 月添加)
70.32.128.48/28(2024 年 4 月添加)
|
Android 虚拟设备(非 Arm) |
34.68.194.64/29(2019 年 11 月添加)
34.69.234.64/29(2019 年 11 月添加)
34.73.34.72/29(2019 年 11 月添加)
34.73.178.72/29(2019 年 11 月添加)
34.74.10.72/29(2022 年 2 月添加)
34.136.2.136/29(2022 年 2 月添加)
34.136.50.136/29(2022 年 2 月添加)
34.145.234.144/29(2022 年 2 月添加)
35.192.160.56/29
35.196.166.80/29
35.196.169.240/29
35.203.128.0/28
35.234.176.160/28
35.243.2.0/27(2019 年 7 月添加)
35.245.243.240/29(2022 年 2 月添加)
199.192.115.0/30
199.192.115.8/30
199.192.115.16/29
|
设备 IP 块不再使用 |
74.125.122.32/29(2022 年 2 月移除)
216.239.44.24/29(2022 年 2 月移除)
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-16。
[null,null,["最后更新时间 (UTC):2025-08-16。"],[],[],null,["\u003cbr /\u003e\n\nFirebase Test Lab lets you quality test your app on a range of devices and\nconfigurations. This guide provides an overview of Test Lab's key concepts,\niOS offerings, and instructions on how to start testing.\n\nFor information about Test Lab quotas and pricing plans, see\n[Usage, Quotas, and Pricing](../usage-quotas-pricing).\n\nKey concepts and terms\n\nWhen you run a test or a set of test cases against devices and configurations\nyou've selected, Test Lab runs the test against your app in a batch, then\ndisplays the results as a **test matrix**.\n\n**Devices × Test Executions = Test Matrix**\n\nDevice\n: A physical or virtual device (Android only) you run a test on, such as a\n phone, tablet, or wearable device. Devices in a test matrix are identified by\n device model, OS version, screen orientation, and locale (also known as\n geography and language settings).\n\nTest, test execution\n: A test (or a set of test cases) to be run on a device. You can run one test\n per device, or optionally shard the test and run its test cases on\n different devices.\n\nTest matrix\n: Contains the statuses and test results for your test executions. If any\n test execution in a matrix fails, the whole matrix fails.\n\n*** ** * ** ***\n\n**Step 1** : Prepare your test for uploading to Test Lab\n\nYou can run the following tests with Test Lab. Note that all test types can\nrun up to a maximum of 45 minutes on physical devices, and any uncaught\nexception will cause a test failure.\n\n- **XCTest (including XCUITests)** : A unit test you've written using the\n [XCTest framework](https://developer.apple.com/documentation/xctest).\n Visit [Create an XCTest](/docs/test-lab/ios/run-xctest) for instructions on modifying an\n XCTest to run with Test Lab.\n\n- **Game Loop test**: A test that uses a \"demo mode\" to\n simulate player actions in gaming apps. This is a fast and scalable way\n to verify that your game performs well for users. When you choose to run a\n Game Loop test, you can:\n\n - Write tests native to your game engine.\n\n - Avoid writing the same code for different UIs or testing\n frameworks.\n\n - Optionally create multiple loops to run in a single test execution. You\n can also organize loops by using labels so you can keep track of them and\n re-run specific loops.\n\n Visit [Run a Game Loop test](/docs/test-lab/ios/run-game-loop-test) for instructions on how to\n run your test in Test Lab.\n\n**Step 2**: Choose a tool to run your test\n\nYou can choose the following tools to run your test with:\n\n- The **Firebase console** lets you upload an\n app and initiate testing from anywhere. See\n [Test with the Firebase console](/docs/test-lab/ios/firebase-console)\n for instructions on using this tool.\n\n- The **gcloud command line interface (CLI)** enables you to run tests\n from the command line interactively, and is also well suited for scripting as\n part of your automated build and testing process. See [Test with the gcloud CLI](/docs/test-lab/ios/command-line)\n for instructions on using this tool.\n\n- Before testing on real devices, run your test **locally on a simulator** to\n make sure it behaves as intended. See\n [Test locally](/docs/test-lab/ios/test-locally) for instructions.\n\n**Step 3**: Specify testing devices\n\nWith Test Lab, you can run your test against your app on a wide range of iOS\ndevices and models hosted in a Google data center. To learn more, see\n[Available devices.](/docs/test-lab/ios/available-testing-devices)\n\n**Step 4**: Review test results\n\nRegardless of how you initiate your tests, all your test results are managed by\nTest Lab and can be viewed online.\n\nThe **test result summary** is\nautomatically stored and can be viewed in the Firebase console. It contains\nthe most relevant data for your test, including test case-specific videos,\nscreenshots, the number of tests that passed, failed, or got flaky results, and\nmore.\n\nThe **raw test results** contain test logs and app failure details, and is\nautomatically stored in a Google Cloud bucket. If you specify a bucket, you are\nresponsible for the cost of the storage. If you don't specify a bucket,\nTest Lab creates one for you at no cost.\n\nFor more details, see\n[Analyze Firebase Test Lab Results.](/docs/test-lab/analyzing-results)\n\nDevice cleanup\n\nGoogle takes the security of your app data very seriously. We follow\nindustry-standard best practices to remove app data and reset system settings\nfor physical devices after every test run to ensure that they are\nready to run new tests. For devices that we can flash with a custom recovery\nimage, we go one step further by flashing these devices between test runs.\n\nFor the virtual devices used by Test Lab, device instances are deleted after\nthey are used so that each test run uses a new virtual device instance.\n\n*** ** * ** ***\n\nAllowing Test Lab devices to access private backend servers\n\nSome mobile apps need to communicate with private backend services to function\ncorrectly during testing. If your backend servers are protected by firewall\nrules, you can allow access for Test Lab's physical and virtual devices by\nusing the [IP address blocks below](#ip-blocks) to open routes through your\nfirewall.\n\nMobile advertising\n\nTest Lab provides a scalable infrastructure that automates app testing, and\nunfortunately, this capability can be misused by malicious apps designed to\ngenerate fraudulent ad revenue.\n\nTo mitigate this issue:\n\n- If you use or work with third-party digital advertising providers\n (for example, ad networks or demand-side platforms),\n you're recommended to use test ads rather than real ads during app development\n and testing.\n\n- If you must use real ads in your test, notify the digital advertising\n providers you work with to filter out revenues and all corresponding traffic\n generated from Test Lab by using the\n [IP address blocks below](#ip-blocks). You don't need\n to notify Google-owned ad providers; Test Lab takes care of that for you.\n\nIP addresses used by Test Lab devices\n\nAll network traffic generated by Test Lab devices originates from the\nfollowing\n[IP address blocks](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation).\nYou can also access this list by using the\n`gcloud beta firebase test ip-blocks list`\n[command](https://cloud.google.com/sdk/gcloud/reference/beta/firebase/test/ip-blocks/list)\nin the [gcloud](https://cloud.google.com/sdk/gcloud) CLI. The list is updated on\naverage once a year.\n\n| Platform and device type | CIDR IP address block |\n|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Android and iOS physical devices, Arm virtual devices | 70.32.128.0/19 (added 02-2022) 108.177.6.0/23 108.177.18.192/26 (added 02-2022) 108.177.29.64/27 (expanded 02-2022) 108.177.31.160/27 (added 02-2022) 199.36.156.8/29 (added 02-2022) 199.36.156.16/28 (added 02-2022) 209.85.131.0/27 (added 02-2022) 2001:4860:1008::/48 (added 02-2022) 2001:4860:1018::/48 (added 02-2022) 2001:4860:1019::/48 (added 02-2022) 2001:4860:1020::/48 (added 02-2022) 2001:4860:1022::/48 (added 02-2022) 70.32.128.48/28 (added 04-2024) |\n| Android virtual devices (Non-Arm) | 34.68.194.64/29 (added 11-2019) 34.69.234.64/29 (added 11-2019) 34.73.34.72/29 (added 11-2019) 34.73.178.72/29 (added 11-2019) 34.74.10.72/29 (added 02-2022) 34.136.2.136/29 (added 02-2022) 34.136.50.136/29 (added 02-2022) 34.145.234.144/29 (added 02-2022) 35.192.160.56/29 35.196.166.80/29 35.196.169.240/29 35.203.128.0/28 35.234.176.160/28 35.243.2.0/27 (added 7-2019) 35.245.243.240/29 (added 02-2022) 199.192.115.0/30 199.192.115.8/30 199.192.115.16/29 |\n| Device IP-blocks no longer being used | 74.125.122.32/29 (removed 02-2022) 216.239.44.24/29 (removed 02-2022) |"]]