# Test your integration Register your test device in the portal, read the log, and run through the checklist for each format. A game not on a store yet can be tested too. *NGA SDK 0.1.0 preview: you install 0.1.0 from Maven Central and NGA's public repositories. Every 0.x version is a preview under the NGA SDK License, and the API can change until 1.0. Questions: hi@nga.network. This page: https://nga.io/docs/sdk/testing/* ## Before you start Testing needs your real app key and placement ids from the portal, and a network connection for the first launch. See [Set up in the portal](https://nga.io/docs/sdk/portal/). ## Test mode Test mode is on if either is true: - **The builder flag**, `testMode(true)`, which the [Initialize](https://nga.io/docs/sdk/initialize/) snippets set in debug builds. - **A registered test device.** Register a phone once in the portal, and every build of every one of your games on it runs in test mode, release builds included. In test mode: - NGA serves your own games, with the same caps as live traffic. - Nothing is paid. - The install's events go to the report's *test view* only, not to your main report or your MMP. **A registered test device sees more than a player does**, among your games whose *Promoted* switch is on: - your other games, as soon as any build of them (debug included) has run once with the SDK on that platform, even before they are promotable to players; - your games that are already installed on it, which a player's device is not shown; - your games that are [not on a store yet](https://nga.io/docs/sdk/portal/#a-game-not-on-a-store-yet), which only registered test devices are shown. ## Register a test device 1. Set the log level to `DEBUG` before `initialize`, as the [Initialize](https://nga.io/docs/sdk/initialize/) snippets do in debug builds. A release build shows the id too, once you call `setLogLevel(DEBUG)` there. 2. Launch the game and find the test-device id in the log, in one of these lines: ```text test-device id (App Set ID): — it covers all your games on this device; add it in the portal to put this device in test mode test-device id (App Set ID): — it covers this game only (this build was not installed by Google Play); add it in the portal to put this device in test mode test-device id (IDFV): — it covers all your games on this device; add it in the portal to put this device in test mode ``` The line says what the id covers: - **Android, a build installed by Google Play** (a testing track or the store): one id for all your games on that device. Register it once. - **Android, a build installed any other way** (Android Studio, `adb`, Firebase App Distribution, a device farm): an id of its own in each game. Register each game's id, on the same device in the portal. Every build you sideload while integrating is this kind, so expect one id per game until your games come from Play. - **iOS**: the IDFV, one id for all your games on that device under one Apple developer account. Register it once. 3. Register it in the portal, under *Test devices*. > **In the portal (portal.nga.io).** > *Test devices* > *Add a device*: a *Name (optional)* and the *Test-device id*, then *Add the device*. A game started in test mode from an id that is not registered yet also appears there, under *Recent test installs not yet registered*, with *Add to device…*, which puts the id on a device you name or one you already have. A device's page lists its ids with what each covers. Remove an id there when you are done. The device enters test mode at the first launch whose init carries its id: | Build | Test mode starts | The id is read | | --- | --- | --- | | Android, release | at the second launch of a fresh install (the first init carries no id) | only if analytics consent is not denied and the player is not under child treatment | | Android, debuggable with `testMode(true)` | at the first launch | always, whatever the consent | | iOS | at the launch after its first events have been sent | under the same rule as an Android release build | If the id is not read (for example, consent denied), only the builder flag applies. The device's page in the portal shows each of your games it ran with the SDK, the consent and configuration in force, its recent ad requests with the reason for each no-fill, and its ad errors. ## The log | Engine | Where to read it | | --- | --- | | Android | Logcat, tag `NGASDK` | | iOS | the Xcode console or Console.app, subsystem `network.nga.sdk`, category `NGASDK` | | Unity | Logcat (Android) or the Xcode console (iOS). The Unity console shows only the C# `[NGA]` lines and your callbacks' own logs | `Terminal` ```shell adb logcat -s NGASDK ``` At `DEBUG`, init logs the test-device id (above) and one summary when it completes: `The DEBUG init summary` ```text init summary test mode: on (the builder's testMode flag) render module: found, nga-sdk-render , started app key: well-formed, accepted by the server placements in the configuration: plc_example_native (native), plc_example_interstitial (interstitial) consent: analytics granted, ads_personalization granted, age unknown, child treatment false; source … server numbers: … ``` - **test mode:** `off`, `on (the builder's testMode flag)`, `on (this device is registered as a test device in the portal)`, or `on (the builder's testMode flag and a registered test device)`. - **render module:** should say `found … started`. Otherwise it says why ad calls fail with `RENDER_NOT_AVAILABLE`: `not found` (the render library is not in the build), or a version that does not match `nga-sdk`. - **app key:** accepted by the server. A launch that started from the saved configuration says so. - **placements in the configuration:** every placement of this game, with its format. A `loadAd` made before init gets a line of its own saying whether its placement is one of them. - **consent:** the consent in effect, the age and whether child treatment applies, and where each came from: your calls, the TCF or GPP keys, or nothing set yet. - **server numbers:** the configuration in force. **An offline first launch prints no summary.** With no network and no saved configuration, init fails with `NETWORK / init.unreachable`, one warning per attempt, and the SDK retries in the background at growing intervals; loads wait for init. The summary comes with the first launch that reaches NGA, and the checklist's airplane-mode check assumes one. **`nga-sdk-render is not in this build`** (iOS: `NGASDKRender`), one `WARN` at `initialize`: the render library is missing, and every ad call answers `RENDER_NOT_AVAILABLE / render.absent`. It never appears when the library is in the build. **`purchase capture off … missing=[permission:com.android.vending.BILLING]`** at start, on an Android emulator image without the Play Store: the permission Play Billing declares is never granted there, so the SDK sees no purchases on that image. A phone with Play grants it. Nothing to fix. Outside test mode the log never prints a player's identifiers; the test-device id is the one exception, so that you can register a release build. **After init, at `DEBUG`, one line per ad event**, with the placement and its format and never an identifier: `The DEBUG ad lines` ```text loadAd plc_example_native (native): served, promoting "Puzzle Example" loadAd plc_example_rewarded (rewarded): joins the load in flight; answered with it loadAd plc_example_rewarded (rewarded): served, promoting com.example.puzzle (2 loadAd calls) loadAd plc_example_interstitial (interstitial): NO_FILL / no_fill.decision show plc_example_native (native): refused ACTIVITY_NOT_RESUMED / show.activity.not_resumed show plc_example_native (native): started show plc_example_native (native): ended, ended_by close ``` - **`loadAd … : served, promoting …`**, with the promoted game's name (the banner) or its package name or bundle id (a full-screen ad), or the error's code and detail, for every load's answer, the loads that waited for init included. A load that answered several `loadAd` calls says how many. - **`loadAd … : joins the load in flight`** for a `loadAd` answered by a load already running, and **`waits for the next attempt in … ms, after …`** for one made while the SDK waits to retry a failed load, so a load you gave up on still leaves a line. - **`show … : refused`** with the code and detail, for every `show` that fails. - **`show … : started`** when the banner has landed or the full-screen ad is on screen (before `onShowStarted`, which is the impression), and **`ended, ended_by …`** when the show ends, with what ended it: `close`, `view_gone`, `window_too_small`, `destroyed`, `process_death`, `child_treatment`, `stopped` (NGA stopped the SDK) or `render_failed`. Log `error.code` and `error.detail` in `onFailed` and `onShowFailed`, and look them up on [Errors](https://nga.io/docs/sdk/reference/errors/). ## "No fill" while testing `NO_FILL` is a normal answer, and the bottom of the screen stays empty. While testing, it usually means one of these: - **You have only one game with the SDK.** A game never promotes itself: a test device needs a second of your games, registered with *Promoted* on (it is on from registration) and run once with the SDK on that platform, any build. The device then asks again within the hour. The test device's page in the portal names this reason. - **For the native banner: NGA has not finished reading your game's listing** ([What the banner shows](https://nga.io/docs/sdk/native-cross-promo/#what-the-banner-shows)). - **For full-screen ads: none of your other games with *Promoted* on has a video** in the portal. - **A cap is reached** (`no_fill.cap`), or **the server asked the device to wait**; `error.retryAfterMillis` says how long. - **The game's *Shows cross-promo* or *Serving* is off**, or the placement's serving is stopped, in the portal. ## Testing your own code A game's own tests reach NGA's part through your own types, not the SDK's: - **Values you can make in a test:** `NGAError`, `NGAResult`, `NGAInitResult`, `NGARewardResult` and `NGAImpression` have public constructors on Android and in C#; on iOS, `NGAError`, `NGARewardResult` and `NGAImpression` have public initializers. - **`NGAAd` is the SDK's handle.** On Android it is an interface and on iOS a protocol, which a test double can implement; in C# it is a sealed class with an internal constructor, so a C# test cannot make one. - So keep the rules your callbacks apply (when to show, what a reward pays, when the banner closes) in your own small interface or class, call the SDK from behind it, and test that. The guide's examples are shaped that way: `InterstitialBackfill` and `RewardedBackfill` hold the rule, and the screens and mediation classes call them. The SDK runs only on a device, an emulator or a simulator: in the Unity Editor `initialize` reports `INVALID_CONFIG / platform.unsupported` and nothing else happens or throws. ## Checklist **Initialize** - `onInitialized` reports `success`, on a device with a network. - Started again in airplane mode, it reports `success` with `fromCache` true. - The `DEBUG` init summary shows the render library found (if your game shows NGA ads), your app key accepted, and your placements in the configuration. **Native cross-promo** - The banner slides up at the bottom of the screen, centered, over nothing of your own. - `onShowStarted` is called about a second after the banner lands. - A tap on the banner opens the store for the promoted game, and `onClicked` is called. For a game not on a store yet, or one already installed on this device, nothing opens; only a test device is shown those. - Closing the banner (its close button, your `close()`, or leaving the screen) calls `onCompleted` then `onClosed` after the impression counted, or `onClosed` alone before it. - Your game calls `close()` before it shows anything of its own at the bottom of the screen, and, in Unity, when it leaves that screen. - If your game shows a banner ad on that screen, it disappears before NGA's banner lands and comes back, refreshing, when NGA's banner closes; and no `NGACrossPromo: no banner yield registered` warning is in the log. - On a tablet, the banner is the tablet size; rotated, it moves to the new bottom center. **Full-screen backfill** - With your mediation filling, NGA's ad never shows and NGA's placement is never loaded. - With your mediation failing, NGA's ad loads and shows at the next ad break. To force a failure in a debug build, change one character of the mediation's ad unit id. - The game pauses before the ad and resumes on `onClosed`. - The close button appears, and back works on Android once it does. **Rewarded** - Watching long enough calls `onRewardResult` with `granted`, once, and your game pays its reward. - Closing early gives `granted` false with `SKIPPED`, and your game says so. - Killing the game mid-ad and relaunching calls `onAdClosedAfterRestart` once, and a reward already paid is not paid again. **Privacy** - Your consent screen's answer reaches `setConsent`, and `getConsent()` returns it. - A *Mixed* game's age gate reaches `setAge`. - Your Data safety and App Privacy answers include the SDK's part; see [Store privacy forms](https://nga.io/docs/sdk/privacy/#store-privacy-forms). **In the portal** - Your test device's page shows your game's launches and its ad requests. - The report's test view shows the impressions and clicks you made. Then [go live](https://nga.io/docs/sdk/go-live/).