Run a GameDriver test on Kobiton

This feature is currently in Beta and is limited to Android devices.

Learn how to run GameDriver tests on real devices using the Turbo Test Execution feature of the Kobiton Platform. Turbo Test Execution enables mobile automation tests to run on the same network as a real device for optimal execution speed and low latency.

Prerequisites

  • A Kobiton subscription that includes GameDriver Turbo Test Execution.

  • An Android app built with Unity with a GameDriver agent already embedded. Learn how to do it here.

  • A GameDriver test project for apps built with Unity. Learn how to create one here.

Prepare the test project package

To run GameDriver tests on the Kobiton platform, expose the testPort environment variable in your test script like the example below:

Expose testPort environment variable in test script

Then, package the test project for local execution. After running your tests against the Unity editor to verify they are functioning as expected, copy the <Test>/bin/Debug directory contents of your test into your Appium <Test>/test folder. For example:

Package your test project for local execution

Copy the <Test>/packages/NUnit.ConsoleRunner.3.12.0/tools directory contents to your <Test>/ext folder.

Archive the <Test> folder into a .zip file, such as test_runner.zip.

Obtain Kobiton API credentials

Log in to the Kobiton Portal using your Kobiton username/email and password.

Select the profile picture, then navigate to Settings.

Navigate to Settings in Kobiton Portal

In the API Keys page, note down the Server URL but remove /wd/hub. For example, if the Server URL is https://api.kobiton.com/wd/hub, then only note down https://api.kobiton.com. This is the <api base url> to be used later.

Note down the API Server URL

Next, note down the value of one of the API Keys. This value, together with the Kobiton account’s username/email, is required to obtain the <credentials> to be used later. Add a new key if there aren’t any.

Note down the API Key

Prepare and collect information from Kobiton

Before you can run the test on Kobiton devices, you need to prepare and collect information from Kobiton. This can be completed by either of these 2 methods:

Method 1: Using Kobiton Portal

Log in to the Kobiton Portal using your Kobiton username/email and password.

Navigate to the application repository by selecting Apps on the navigation pane.

Select the + icon to upload an app.

Select the plus icon to upload an app

Wait until the below File uploaded successfully…​ message appears.

File uploaded successfully message

Refresh the page until the message is replaced by your app icon. See below for an example. Then, select the newly uploaded app.

Open the uploaded app

Make sure the screen displays the app version as below, then select the Automation Snippet icon.

Select Automation Snippet

Note down the value in the text field. This is the <app url> to be used later.

Note down automation snippet value

Navigate to the Device list by selecting Devices on the navigation pane.

Select the 3-dot icon on the Android device you plan to use for testing.

Navigate to Devices and select the 3-dot icon on an Android device

Note down the device’s UDID. This is the <udid> to be used later. Select Automation Settings.

Note down the device UDID, then select Automation Settings

In the Framework dropdown, select UIAutomator/ Espresso.

Select UIAutomator or Espresso

Scroll down until you find the Test Runner section, then select Upload Test Runner.

Select Upload Test Runner under the Test Runner section

Choose the test_runner.zip file and select Open.

When the file finishes uploading, note down the value of Test Runner Url. This is the <test runner url> to be used later.

Note down the value of Test Runner URL

Method 2: Using Kobiton API

Run the following API endpoints in order to upload an app to the Kobiton application repository:

Append the version_id from the response of the last endpoint to the text below. This is the <app url> to be used later.

kobiton-store:v<version_id>

Run the following API endpoints, in order, to upload the test runner to Kobiton:

Note down the value of url from the response of the last endpoint. This is the <test runner url> to be used later.

Run the List all devices API endpoint to find an Android device to use for your testing. Note down the value of udid in the response of the desired device. This is the <udid> to be used later.

Run the automation test

Open a terminal in your computer and enter the following command:

curl --location '<api base url>/v2/sessions/native' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <credentials>' \
--data '{
    "session_description": "<session description>",
    "session_name": "<session name>",
    "test_framework": "GAMEDRIVER",
    "app": "<app url>",
    "run_command": "mono <path to nunit runner> <path to test script> --testparam:Mode=standalone --testparam:testHost=localhost --testparam:testPort=<gdio port>",
    "test_runner": "<test runner url>",
    "root_directory": "<root directory name>",
    "udid": "<udid>",
    "device_name": "<device name>",
    "platform_version": "<device OS version>"
}'

Fill in the variable information in the command based on the below table:

C#

Parameter Type Required? Example Description

<api base url>

string

Yes

https://api.kobiton.com

API base URL

<credentials>

string

Yes

a29iaXRvbmFkbWluOjI4Nzk4MTI0LTItZGEtd2Rhdy0tNDMtMjQzMjQ=

Base64 encoding of username/email and API key joined by a single colon :

<session description>

string

No

A gaming session

Description of the session

<session name>

string

No

Gaming session

Default value: Session created at <date> <time>

Name of the session

<app url>

string

Yes

kobiton-store:v205170

URL of the application to be tested

<path to nunit runer>

string

Yes

./ext/nunit3-console.exe

Path to the nunit3-console.exe file from the root directory

<path to test script>

string

Yes

./test/NewAPI_MobileTennis_Test.dll

Path to the test script DLL file from the root directory

<gdio port>

string

Yes

KOBITON_GDIO_PORT

19734

The local port to run GameDriver test on. Use either KOBITON_GDIO_PORT to let the system automatically decide, or use the default 19734 port

<test runner url>

string

Yes

https://kobiton-prod-blue.s3.amazonaws.com/test-runner/users/17/test_runner-cfc2d590-5067-11ee-b387-71e5b022613e.zip

Download URL of the test runner

<root directory name>

string

Yes

test_runner

Name of the root directory in the test runner package that contains the ext and test folder

<udid>

string

Yes if <device name> is not provided

8bf2c82a-5053-11ee-be56-0242ac120002

UDID of the Kobiton device to run a test on

<device name>

string

Yes if <udid> is not provided

Pixel 6

* (wildcard)

Display name of the device on the Kobiton Portal

<platform version>

string

No

12

OS version of the device

Run the command with all the required information filled in. The system then finds the 1st device that matches either <udid>, or the <device name> and <platform version> pair and runs the test script on it. If successful, the response is similar to the below example. Note down the value of <Gaming session ID> to retrieve the logs and test results of the session.

{"id":<Gaming session ID>}%

View GameDriver test report

Method 1: On Kobiton Portal

Log in to the Kobiton Portal using your Kobiton username/email and password.

Navigate to Sessions, then input the <Gaming session ID> obtained from running the test above into the search bar. Select the session in the search results to navigate to the session details.

Provide the Gaming session ID in the search box of the Session list

Under Test Report, select download to save the test report to your computer. Note: the test report can only be downloaded for sessions with the status: Complete.

Select download under Test Report

Method 2: Using Kobiton API

Pass the <Gaming session ID> obtained from running the test into Get a session API endpoint to retrieve the details of your GameDriver session.

In the response, the value of test_report_url is the download link of the test report. Use the link to save the test report to your computer.