<br />

[Video](https://www.youtube.com/watch?v=Gsd26EuSg4g)

This guide explains how to enable test ads in your ads integration. It's
important to enable test ads during development so that you can click on them
without charging Google advertisers. If you click on too many ads without being
in test mode, you risk your account being flagged for invalid activity.

There are two ways to get test ads:

1. Use one of Google's sample ad units.

2. Use your own ad unit and enable test devices.

## Prerequisites

- Complete [Get Started](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/quick-start.md.txt).

- Import Google Mobile Ads Unity Plugin to your Unity app.

## Sample ad units

The quickest way to enable testing is to use Google-provided test ad units.
These ad units are not associated with your Ad Manager account, so there's no
risk of your account generating invalid traffic when using these ad units.

It is important to note that different Google-provided test ad units should be
used depending on the platform. You'll need to use an iOS test ad unit for
making test ad requests on iOS and an Android test ad unit for making requests
on Android.

> [!IMPORTANT]
> **Key Point:** Make sure you replace these test IDs with your own ad unit ID before publishing your app.

Here are sample ad units for each format on both Android and iOS:

| Ad format | Sample ad unit ID |
|---|---|
| [App open](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/app-open.md.txt) | `/21775744923/example/app-open` |
| [Fixed Size Banner](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/banner.md.txt) | `/21775744923/example/fixed-size-banner` |
| [Anchored Adaptive Banner](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/banner/anchored-adaptive.md.txt) | `/21775744923/example/adaptive-banner` |
| [Interstitial](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/interstitial.md.txt) | `/21775744923/example/interstitial` |
| [Rewarded](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/rewarded.md.txt) | `/21775744923/example/rewarded` |
| [Rewarded Interstitial](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/rewarded-interstitial.md.txt) | `/21775744923/example/rewarded-interstitial` |
| [Native](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/native-overlay.md.txt) | `/21775744923/example/native` |
| [Native Video](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/native-overlay.md.txt) | `/21775744923/example/native-video` |
| [Picture-in-picture](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/picture-in-picture.md.txt#load_ad) | `/21775744923/example/picture-in-picture` |

These ad units point to specific test creatives.

## Enable test devices

If you want to do more rigorous testing with production-looking ads, you can
now configure your device as a test device and use your own ad unit IDs that
you've created in the Ad Manager web interface. Test devices can either be added
in the web interface or programmatically using Google Mobile Ads Unity Plugin.

Follow the steps below to add your device as a test device.

> [!IMPORTANT]
> **Key Point:** Android emulators and iOS simulators are automatically configured as test devices.

### Add your test device in the Ad Manager web interface

For a simple, non-programmatic way to add a test device and test new or existing
app builds, use the Ad Manager web interface.

> [!IMPORTANT]
> **Key Point:** New test devices typically start serving test ads in your app within 15 minutes, but it can also take up to 24 hours.

### Add your test device programmatically

If you want to test ads in your app as you're developing, follow the
steps below to programmatically register your test device.

1. Run an app configured with Google Mobile Ads Unity Plugin and make an ad request
   using one of the test ad unit IDs listed above.
   [Code listing](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/banner.md.txt#create_a_banner_view).

   ```c#
   ...
   private void RequestBanner()
   {
       #if UNITY_ANDROID
           string adUnitId = "ca-app-pub-3940256099942544/6300978111";
       #elif UNITY_IPHONE
           string adUnitId = "ca-app-pub-3940256099942544/2934735716";
       #else
           string adUnitId = "unexpected_platform";
       #endif

       // Create a 320x50 banner at the top of the screen.
       bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
       // Create an empty ad request.
       AdRequest request = new AdRequest();
       // Load the banner with the request.
       bannerView.LoadAd(request);
   }
   ```
2. Check the console or logcat output for a message that looks like this:

   ### Android

   ```
   I/Ads: Use
     RequestConfiguration.Builder
       .setTestDeviceIds(Arrays.asList("33BE2250B43518CCDA7DE426D04EE231"))
     to get test ads on this device.
   ```

   ### iOS

   ```
   <Google> To get test ads on this device, set:
     GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers =
     @[ @"2077ef9a63d2b398840261c8221a0c9b" ];
   ```
3. Copy your alphanumeric test device ID to your clipboard.

4. Modify your code to add the test device IDs to your
   `RequestConfiguration.TestDeviceIds` list.

   ```c#
   RequestConfiguration requestConfiguration = new RequestConfiguration();
   requestConfiguration.TestDeviceIds.Add("2077ef9a63d2b398840261c8221a0c9b");
   ```
   Be sure to remove the code that sets these test devices before you release your app.
5. Set `requestConfiguration` globally to `MobileAds`.

   ```c#
   MobileAds.SetRequestConfiguration(requestConfiguration);
   ```
6. Re-run your app. If you correctly added your device as a test device, you
   will see a **Test Ad** label centered at the top of banner, interstitial,
   and rewarded ads:

   ![](https://developers.google.com/static/admob/images/android-testad-0-admob.png)

   Ads with this **Test Ad** label are safe to click. Any requests,
   impressions, and clicks on test ads do not show up in your account's
   reports.
   Mediated ads DO NOT render a **Test Ad** label.
7. Now that your device is registered as a test device, you can begin receiving
   more realistic test ads by replacing the test `adUnitID` with your own
   `adUnitID`.

### Testing with the Unity Editor

Beginning with version 5.4.0, you can test your ads directly in the
Unity editor. The editor will add a Prefab image giving a similar experience to
how actual ads will behave on a mobile platform.

![](https://developers.google.com/static/admob/images/unity_test_ad_editor.gif)

> [!NOTE]
> **Note:** Because the mock ads are prefab objects, they will appear "under" your GUI in the Unity Editor. When you export to a mobile platform, however, ads render on top of any game views.

## Testing with mediation

Google's sample ad units only show Google Ads. To test your mediation
configuration, you must use the [enable test devices](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/test-ads.md.txt#enable_test_devices)
approach.

Mediated ads do *NOT* render a **Test Ad** label. You are responsible for
ensuring that test ads are enabled for each of your mediation networks so these
networks don't flag your account for invalid activity. See each network's
respective [mediation guide](https://developers.google.com/ad-manager/mobile-ads-sdk/unity/mediation.md.txt) for more
information.

If you aren't sure whether a mediation ad network adapter supports test ads, it
is safest to avoid clicking on ads from that network during development. You
can use the `MediationAdapterClassName()` method on any of the ad formats to
figure out which ad network served the current ad.