> [!WARNING]
> **DEPRECATED:** The Google Mobile Ads C++ SDK is *deprecated* as of June 17, 2024 and should not be adopted in projects that don't already use it. It will enter *End-of-Maintenance (EoM)* on June 17, 2025. Note that versions of the SDK released before the EoM date will continue to function, but no further bug fixes or changes will be released after the EoM date.
>
> Instead of the Google Mobile Ads C++ SDK, consider using the
> [iOS](https://developers.google.com/admob/ios/quick-start.md.txt) and
> [Android](https://developers.google.com/admob/android/quick-start.md.txt) SDKs from AdMob.
> For support, reach out to the
> [contact us form](https://support.google.com/admob/contact/contact_us_gma_sdk).

<br />

This guide explains how to receive test ads in your ads integration. It is
important to use 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 [demo ad units](https://developers.google.com/admob/cpp/test-ads.md.txt#demo_ad_units).

2. Use your own ad unit and [enable test mode](https://developers.google.com/admob/cpp/test-ads.md.txt#enable_test_devices).

## 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 AdMob account, so there's no risk of
your account generating invalid traffic when using these ad units.

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

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

### Android

| Ad format | Sample ad unit ID |
|---|---|
| [Banner](https://developers.google.com/admob/cpp/banner.md.txt) | `ca-app-pub-3940256099942544/6300978111` |
| [Interstitial](https://developers.google.com/admob/cpp/interstitial.md.txt) | `ca-app-pub-3940256099942544/1033173712` |
| [Rewarded](https://developers.google.com/admob/cpp/rewarded.md.txt) | `ca-app-pub-3940256099942544/5224354917` |

### iOS

| Ad format | Sample ad unit ID |
|---|---|
| [Banner](https://developers.google.com/admob/cpp/banner.md.txt) | `ca-app-pub-3940256099942544/2934735716` |
| [Interstitial](https://developers.google.com/admob/cpp/interstitial.md.txt) | `ca-app-pub-3940256099942544/4411468910` |
| [Rewarded](https://developers.google.com/admob/cpp/rewarded.md.txt) | `ca-app-pub-3940256099942544/1712485313` |

## Enable test devices (Test mode)

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 AdMob UI. Test devices can either be added in the AdMob UI or
programmatically using the Google Mobile Ads SDK.

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

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

### Add your test device in the AdMob UI

For a simple, non-programmatic way to add a test device and test new or existing
app builds, use the AdMob UI.
[Learn how](https://support.google.com/admob/answer/9691433).

> [!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. Load your ads-integrated app and make an ad request.

2. Check the console for a message that looks like this:

   ### Android

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

   ### iOS

   ```c++
    <Google> To get test ads on this device, set:
    GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = @[ @"2077ef9a63d2b398840261c8221a0c9b" ];
    
   ```

   Copy your test device ID to your clipboard.

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

3. Modify your code to set the test device ID through `SetRequestConfiguration`:

   ```c++
     // Set a sample device ID of 2077ef9a63d2b398840261c8221a0c9b
     firebase::gma::RequestConfiguration request_configuration =
       firebase::gma::GetRequestConfiguration();
     request_configuration.test_device_ids.push_back("2077ef9a63d2b398840261c8221a0c9b");
     firebase::gma::SetRequestConfiguration(request_configuration);
   ```
4. Re-run your app. If the ad is a Google ad, you'll see a **Test mode** label
   centered at the top of the ad (banner, interstitial, or rewarded ad):

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

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

> [!IMPORTANT]
> **Key Point:** Mediated ads do NOT render a **Test mode** label. See the section below for details.

## Testing with mediation

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

Mediated ads do not render a **Test mode** label. You are responsible for ensuring
that test mode is enabled for each of your mediation networks so that these
networks don't flag your account for invalid activity. See each network's
respective [mediation guide](https://developers.google.com/admob/cpp/mediation.md.txt) for more
information.

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