<br />

This guide explains how to enable test ads for your ads integration. It's
recommended that you enable test ads during development so you can test
click-through behavior without affecting your reservation campaigns' stats or
charging advertisers on Ad Exchange.

<br />

## Prerequisite

Before you continue, [set up Google Mobile Ads SDK (Legacy)](https://developers.google.com/ad-manager/mobile-ads-sdk/android/quick-start.md.txt).

## Demo ad units

The quickest way to enable testing is to use Google-provided demo 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.

> [!WARNING]
> **Warning:** Before publishing your app, make sure that you replace these IDs with your ad unit ID. If you've published your app, [enable test devices](https://developers.google.com/ad-manager/mobile-ads-sdk/android/test-ads.md.txt#enable_test_devices).

Here are demo ad units that point to specific test creatives for each format:

| Ad format | Demo ad unit ID |
|---|---|
| [App Open](https://developers.google.com/ad-manager/mobile-ads-sdk/android/app-open.md.txt) | `/21775744923/example/app-open` |
| [Achored Adaptive Banner](https://developers.google.com/ad-manager/mobile-ads-sdk/android/banner.md.txt) | `/21775744923/example/adaptive-banner` |
| [Inline Adaptive Banner](https://developers.google.com/ad-manager/mobile-ads-sdk/android/banner/inline-adaptive.md.txt) | `/21775744923/example/adaptive-banner` |
| [Fixed Size Banner](https://developers.google.com/ad-manager/mobile-ads-sdk/android/banner/fixed-size.md.txt) | `/21775744923/example/fixed-size-banner` |
| [Interstitial](https://developers.google.com/ad-manager/mobile-ads-sdk/android/interstitial.md.txt) | `/21775744923/example/interstitial` |
| [Rewarded Ads](https://developers.google.com/ad-manager/mobile-ads-sdk/android/rewarded.md.txt) | `/21775744923/example/rewarded` |
| [Rewarded Interstitial](https://developers.google.com/ad-manager/mobile-ads-sdk/android/rewarded-interstitial.md.txt) | `/21775744923/example/rewarded-interstitial` |
| [Native](https://developers.google.com/ad-manager/mobile-ads-sdk/android/native.md.txt) | `/21775744923/example/native` |
| [Native Video](https://developers.google.com/ad-manager/mobile-ads-sdk/android/native/video-ads.md.txt) | `/21775744923/example/native-video` |
| [Picture-in-picture](https://developers.google.com/ad-manager/mobile-ads-sdk/android/picture-in-picture) | `/21775744923/example/picture-in-picture` |

Key Point: These demo ad units are configured to serve direct-sold ads in Ad Manager, and direct-sold ads do not return AdChoices.

## 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 UI.


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

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

### Add your test device programmatically

To register your test device, complete the following steps:

1. Load your ads-integrated app and make an ad request.
2. Check the logcat output for a message similar to the following, which shows you your device ID and how to add it as a test device:

   ```
   I/Ads: Use RequestConfiguration.Builder.setTestDeviceIds(Arrays.asList("33BE2250B43518CCDA7DE426D04EE231"))
   to get test ads on this device."
   ```
   Copy your test device ID to your clipboard.
3. Modify your code to call

   [`RequestConfiguration.Builder.setTestDeviceIds()`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/RequestConfiguration.Builder.md.txt#setTestDeviceIds(java.util.List%3Cjava.lang.String%3E))

   and pass in a list of your test device IDs.

   ### Java

   ```java
   List<String> testDeviceIds = Arrays.asList("TEST_DEVICE_ID");
   RequestConfiguration configuration =
       new RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build();
   MobileAds.setRequestConfiguration(configuration);
   ```

   ### Kotlin

   ```kotlin
   val testDeviceIds = listOf("TEST_DEVICE_ID")
   val configuration = RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build()
   MobileAds.setRequestConfiguration(configuration)
   ```

   Replace <var translate="no">TEST_DEVICE_ID</var> with your test device ID.

   You can optionally check

   [`isTestDevice()`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AdRequest.md.txt#isTestDevice(android.content.Context))

   to confirm that your device was properly added as a test device.

   > [!CAUTION]
   > **Caution:** Be sure to remove the code that sets these test device IDs before you release your app.

4. Re-run your app. If the ad is a Google ad, you'll see a **Test Ad** label
   centered at the top of the ad (banner, interstitial, or rewarded video):

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

   > [!NOTE]
   > **Note:** To see the **Test Ad** label, you need to be using an SDK version of 11.6.0 or higher.

   For native advanced ads, the headline asset is prepended with the string **Test Ad**.

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

Ads with this **Test Ad** label are safe to click. Requests, impressions, and
clicks on test ads won't show up in your account's reports.

> [!NOTE]
> **Note:** Mediated ads do *NOT* render a **Test Ad** label. See the following section for details.

## 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/android/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/android/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

[`getMediationAdapterClassName()`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/ResponseInfo.md.txt#getMediationAdapterClassName())

method on any of the ad formats to figure out which ad network served the
current ad.