Share your feedback about the Google Mobile Ads SDK! Take the annual survey.

Mediation Test Suite

The AdMob Mediation Test Suite allows you to test whether you have correctly configured your application and ad units to be able to display ads from third-party networks via AdMob mediation.

This guide outlines how to use the AdMob Mediation Test Suite in your iOS app. The first step is integrating the tool into your app.

Prerequisites

  • Use Xcode 10 or higher.

  • Target iOS 8.0 or higher.

Installation

The Mediation Test Suite is installed using CocoaPods. To do this, add the following line to your Podfile:

pod 'GoogleMobileAdsMediationTestSuite'

This configures the test suite as well as the required Material Components dependencies. Run pod install to complete the installation.

Launching the Mediation Test Suite

Setup

To display the tool, first import the framework:

Swift

import GoogleMobileAdsMediationTestSuite

Objective-C

@import GoogleMobileAdsMediationTestSuite;

Next, after your view has appeared, show the test suite as follows:

Swift

GoogleMobileAdsMediationTestSuite.present(on:self, delegate:nil)

Objective-C

[GoogleMobileAdsMediationTestSuite presentOnViewController:self delegate:nil];

Note that this requires that you have correctly entered your AdMob app ID in your Info.plist.

Also note that the delegate is optional and is provided only if you want to be notified when the tool is dismissed. To implement the delegate callback, conform to the GMTSMediationTestSuiteDelegate protocol and implement the mediationTestSuiteWasDismissed method.

Launching the test suite

The tool opens with the following disclaimer:

Tick the checkbox and press Agree to proceed.

You're then presented with a list of ad units for your account, separated into two tabs: Failing Ad Units and Working Ad Units.

The Failing Ad Units list is separated into Missing Components and Configuration Errors:

After all of an ad unit's networks are tested successfully, the ad unit will move from the Failing tab to the Working tab. If you don't see a list of ad units, either the network call failed or no ad units were found.

If you want to search the list of ad units, press the search icon at the top and enter a string of an ad unit ID. You can also search by network name or by ad format.

The screen indicates, for a given ad unit, whether:

  • the SDK is installed
  • the adapter is installed

Select an ad unit to move to the Ad Unit Details screen.

Ad Unit Details

This screen shows the details for the ad unit, including the ad unit ID, the ad format, and the mediation waterfall configured for the ad unit:

Note the following aspects on this screen:

Ad Source Summary

For each ad source, there are indicators showing whether the SDK and adapter is installedand the result of the last test for this configuration in this session.

Note that for custom events, a Custom Event: Your custom event label is used. The adapter status indicator for a custom event will be positive if the class you've specified for the custom event is found. You can load and view ads for custom events in the same way as other networks.

Search

Pressing the search icon presents a search screen where you can search for ad sources according to their name.

Batch testing

Each ad source can be selected to be tested in a batch by checking the checkbox to the left of the ad source name. A new option then appears in the navigation bar:

Press the Load Ads button in the top right to load ads for the selected ad sources in sequence. A progress indicator is displayed while testing takes place. Pressing the back icon in the top left clears the selection.

Loading and displaying ads

Tap on an ad source entry to see the ad source details screen:

The screen indicates, for the given ad source, whether:

  • the SDK is installed
  • the adapter is installed
  • the parameters for the configuration have been entered in the AdMob console

After you've installed all required components, you can proceed to test loading an ad. Tap on Load Ad to send an ad request to the ad source's SDK. Once the ad request completes, an update saying whether the request succeeded or failed is presented.

If the request failed, check your console logs for messages from the SDK being tested.

If the request succeeded:

  • For banner ads, the ad is shown inline.
  • For interstitial or rewarded ads, you can show the ad by tapping on Show Ad.

    The ad opens in a new screen, for example:

When you return to the Ad Unit Details screen, the results of the last time you tested the ad in the ad units list screen are displayed. The successfully loaded ad sources are moved to the bottom of the list surfacing the ad sources needing further testing. Note that these results are not persisted across sessions.

Enabling testing in production

By default, the mediation test suite will only launch in development, adhoc, and enterprise builds. This is meant to prevent end users from inadvertently launching the test suite.

If you need to run the mediation test suite on a device once your app is in production, you should whitelist your device using the AdMob test device ID retrieved from your console logs prior to distributing the build.

To add the device to the whitelist, add the test device ID to GADRequest.testDevices and then set the configured ad request to be used by the mediation test suite:

Swift

let request = GADRequest()
request.testDevices = [ "2077ef9a63d2b398840261c8221a0c9b" ] // Sample device ID
GoogleAdsMediationTestSuite.setAdRequest(request);

Objective C

GADRequest *request = [GADRequest request];
request.testDevices = @[ @"2077ef9a63d2b398840261c8221a0c9b" ]; // Sample device ID
[GoogleAdsMediationTestSuite setAdRequest:request];

When including the mediation test suite in a production app, you'll need a hidden way to launch the test suite (for example, a secret gesture or debug menu). You’ll then be able to launch the test suite on any device that’s been whitelisted in the build.

Configuring ad requests with network extras (optional)

Certain mediated networks, such as Vungle, require or have the option to provide a custom network extras object to provide additional information to requests to their network. If you need to provide network extras for your mediation requests you can set an ad request for the test suite to use using the[GoogleAdsMediationTestSuite setAdRequest:] static method:

Swift

let request = GADRequest()
...
// Set your network extras for your chosen networks here.
// i.e for each network extras object, call 'request.register(<network extras>)'
...
GoogleAdsMediationTestSuite.setAdRequest(request);

Objective-C

GADRequest request = [GADRequest request];
...
// Set your network extras for your chosen networks here.
// i.e for each network extras object, call '[request registerAdNetworkExtras:<network extras>];'
...
[GoogleAdsMediationTestSuite setAdRequest:request];

Ensure that you do this before launching the mediation test suite.

This enables you to instantiate and configure an ad request with any required extras, which the test suite can then use in its request to the mediated network.

Advanced CocoaPods configuration (optional, debug only)

If you only want to include the pod in the debug version of your app, you can specify this in your Podfile as a pod for only the Debug build configuration. You need to also guard any code that calls the tool with #ifdef DEBUG statements or similar.

To include the pod only in the Debug configuration, use the following line:

pod 'GoogleMobileAdsMediationTestSuite', :configurations => ['Debug'], :path => '/path/to/GoogleMobileAdsMediationTestSuite/'

Make sure to wrap all references to the framework and its classes with #ifdef DEBUG:

Swift

import UIKit
#if DEBUG
import GoogleMobileAdsMediationTestSuite
#endif
import GoogleMobileAds

let APP_ID = "ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

  @IBAction func presentMediationController(_ sender: AnyObject) {
      #if DEBUG
        GoogleMobileAdsMediationTestSuite.present(withAppId:APP_ID, on:self, delegate:nil)
      #endif
    }

Objective-C

#import "ViewController.h"
#ifdef DEBUG
@import GoogleMobileAdsMediationTestSuite;
#endif
#import <GoogleMobileAds/GoogleMobileAds.h>

static NSString *APP_ID = @"ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy";

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
}

- (IBAction)presentMediationController:(id)sender {
#ifdef DEBUG
    [GoogleMobileAdsMediationTestSuite presentWithAppId:APP_ID
                                       onViewController:self
                                               delegate:nil];
  }
#endif
}

Frequently Asked Questions

Does the disclaimer show every time?
Yes, we do this intentionally as a reminder that you should turn on test mode for your mediation ad sources.
Why do I see AdMob multiple times on the Ad Unit details page?
If multiple mediation groups target the same ad unit, we combine all of the groups together. For example, you may see multiple AdMob entries and possibly multiple of other ad sources. Even inside the same mediation group, a mediation partner can be defined up to 3 times.
Which networks / ad sources are supported by the mediation test suite?
The test suite works for all open source and versioned adapters as well as custom event adapters. The ad networks in our open source initiative are listed on our mediation page.