测试广告单元
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
广告检查器支持以下两种测试:
- 上下文内测试:从应用中的广告单元加载广告。您可以打开广告检查器,查看从广告单元发出的请求的详细信息。
- 上下文外测试:直接在广告检查器中测试广告单元,而无需前往应用界面。您可以同时测试多个广告单元、异步加载和查看测试广告请求,以及执行单一广告来源测试。
运行上下文外测试时,您的请求不会包含那些在应用界面中运行所需的参数,这包括面向儿童的内容配置、自定义定位、广告联盟额外信息和不同的尺寸。由于这些请求存在限制,我们建议您在应用界面中使用上下文内测试。
前提条件
在继续操作之前,请先完成以下事项:
- 完成初始前提条件中的所有事项,以创建 AdMob 账号、设置测试设备、初始化 Google 移动广告 SDK,以及安装最新版本。
- 启动广告检查器。
请求测试广告
如需在广告检查器中请求测试广告,请完成以下步骤。如需了解详情,请参阅如何在应用中使用广告检查器。
上下文内测试:
- 在测试设备上,前往应用界面并加载广告。
- 打开广告检查器。在 Ad unit(广告单元)标签页中,找到加载了广告的广告单元。
- 在 SDK request log(SDK 请求日志)中,查看您所请求测试广告的详细信息。
Out-of-context:
- 在 Ad unit(广告单元)标签页中,点按您的广告单元,然后点击 Request test ad(请求测试广告)。
- 在 SDK request log(SDK 请求日志)中,查看您所请求测试广告的详细信息。

如果广告单元格式显示为 Unknown(未知),您会看到 Request test ad(请求测试广告)显示为灰色。
测试单一广告来源
广告检查器可以限制应用中的广告请求,只投放来自单个出价广告来源或瀑布流广告来源的广告。通过这种方法,您可以验证是否已正确集成第三方适配器,以及该广告来源能否按预期投放广告。
如需测试单一广告来源,请完成以下步骤:
在 Ad inspector(广告检查器)页面中,点击 Single ad source test(单一广告来源测试)切换开关。系统会显示 Single ad source test(单一广告来源测试)对话框:
选择要测试的广告来源。之后,您会看到 Force restart app(强制重启应用)页面:

单一广告来源测试的设置适用于今后发出的所有广告请求。此测试不适用于该会话中之前已缓存的广告。我们建议您在采用单一广告来源测试时强制重启应用。这样可以使已缓存的广告失效,防止它们代替您所选的广告来源响应广告请求。
重启应用后,所有广告单元展示位置都会尝试展示来自所选广告来源的广告。在执行单一广告来源测试时,启动广告检查器即会显示当前测试的广告来源:

在单一广告来源测试模式下,所有广告请求都会尝试从所选广告来源填充广告,无论该广告来源配置为出价模式还是广告瀑布流模式。如果您要测试的广告来源并未在广告单元中设置为出价模式或广告瀑布流模式,您会收到以下错误消息:
Ad Unit has no applicable adapter for single ad source testing on network: AD_SOURCE_ADAPTER_CLASS_NAME
如需验证广告来源是否在您开始单一广告来源测试后填充了广告请求,请点按某个广告单元以查看 SDK 请求日志。如果广告来源未能加载广告,系统会显示一条错误消息来说明相应错误,例如 Adapter failed to initialize
。
如果您向某个广告瀑布流多次添加了所选广告来源,则会看到对该广告来源的每次调用。此过程会持续进行,直到广告填充成功,或者广告瀑布流结束而无任何广告填充为止。
停止单个广告来源测试
如需停止测试,请完成以下步骤:
- 在 Ad inspector(广告检查器)页面中,将 Single ad source test(单一广告来源测试)切换为关闭状态。系统会显示 Stop single ad source test?(要停止单一广告来源测试吗?)对话框。
点按 Stop test(停止测试)。

如果成功,Force restart app(强制重启应用)上方会显示确认消息:

为了撤消所测试广告来源的缓存广告,我们建议您在停止测试后强制重启应用。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-27。
[null,null,["最后更新时间 (UTC):2025-08-27。"],[],[],null,["Select platform: [Android](/admob/android/ad-inspector/test-ad-units \"View this page for the Android platform docs.\") [iOS](/admob/ios/ad-inspector/test-ad-units \"View this page for the iOS platform docs.\") [Unity](/admob/unity/ad-inspector/test-ad-units \"View this page for the Unity platform docs.\") [Flutter](/admob/flutter/ad-inspector/test-ad-units \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nAd inspector supports the following tests:\n\n- **In-context testing**: load ads from the ad units in your app. You can open ad inspector to view details on requests made from ad units.\n- **Out-of-context testing**: test your ad unit directly in ad inspector without navigating to your app's UI. You can test multiple ad units at once, asynchronously load and view your test ad requests, and perform single ad source tests.\n\nWhen running an out-of-context test, your requests don't carry the parameters\nto run in your app's UI, including child-directed treatment configuration,\ncustom targeting, network extras, and different sizes. Due to the limitation of\nthese requests, we recommend you use in-context testing in your app's UI.\n\nPrerequisites\n\nBefore you continue, do the following:\n\n- Complete all items in the initial [Prerequisites](/admob/ios/ad-inspector#prerequisites) to create an AdMob account, set your test device, initialize Google Mobile Ads SDK, and install the latest version.\n- [Launch ad inspector](/admob/ios/ad-inspector/launch-ad-inspector).\n\nRequest a test ad\n\nTo request a test ad in ad inspector, complete the following steps. For more\ndetails, see\n\n[How to use ad inspector in your app](//support.google.com/admob/answer/13063114).\n\n\n- **In-context**:\n\n 1. On a test device, navigate to your app's UI and load an ad.\n 2. Open ad inspector. In the **Ad unit** tab, find the ad unit where you loaded the ad.\n 3. In **SDK request log**, view details on your requested test ad.\n- **Out-of-context**:\n\n 1. In the **Ad unit** tab, tap on your ad unit and click **Request test ad**.\n 2. In **SDK request log**, view details on your requested test ad.\n\nIf the ad unit format shows **Unknown** , you see **Request test ad** greyed\nout.\n\nTest a single ad source\n\nAd inspector can restrict ad requests in your app to serve ads from a single\nbidding or waterfall ad source. This approach lets you verify that you've\ncorrectly integrated with the third-party adapter, and the ad source serves\nas expected.\n\nTo test a single ad source, complete the following steps:\n\n1. In **Ad inspector** , click the **Single ad source test** toggle. A\n **Single ad source test** dialog appears:\n\n\n2. Select an ad source to test. Afterwards, you receive the\n **Force restart app** page:\n\nThe single ad source test setting applies to any future ad requests you make.\nThis test doesn't apply to previously cached ads in that session.\nWe recommend you to force restarting your app when applying a single ad source\ntest. This approach invalidates cached ads that might display instead of\nyour chosen ad source receiving a request.\n\nAfter restarting your app, all ad unit placements attempt to show an ad from the\nselected ad source. Launching ad inspector when a single ad source test is\nactive shows the active test ad source:\n\nIn single ad source test mode, all ad requests attempt to fill with the\nselected ad source, regardless of whether that ad source was configured for\nbidding or waterfall. If the ad source you're testing is not set up for bidding\nor waterfall for the ad unit, you receive the following error message: \n\n Ad Unit has no applicable adapter for single ad source testing on network: \u003cvar translate=\"no\"\u003eAD_SOURCE_ADAPTER_CLASS_NAME\u003c/var\u003e\n\nTo verify whether the ad source filled the ad requests after you start a single\nad source test, tap an ad unit to view the SDK request log. If the ad source\nfailed to load an ad, an error message appears describing the error, such\nas `Adapter failed to initialize`.\n\nIf you've added multiple instances of the selected ad source to a waterfall, you\nsee each call instance to the ad source. This process renders until the ad is\neither filled or the waterfall ends without a fill.\n\nStop a single ad source test\n\nTo stop the test, complete the following steps:\n\n1. In **Ad inspector** , click off the **Single ad source test** toggle. The **Stop single ad source test?** dialog appears.\n2. Tap **Stop test**.\n\n\n If successful, a confirmation message appears over **Force restart app**:\n\nTo revoke cached ads for the tested ad source, we recommend you to force\nrestart the app after stopping the test."]]