Real Device Hot Instant access to a wide range of iOS and Android real devices
Automation Hot Perform mobile app automated testing in popular frameworks
WeTest Monkey Quickly find basic compatibility issues
PerfDog Hot A client performance testing expert service package
Game Loop
Help Documents menu

Game Loop

Updated on: 2022-09-26 16:03

Accoding to various UI framework in Game Testing, it is difficult to run automated testing. WeTest Game Loop Testing is able to launch your test App multiple times against a wide range of Android and iOS real devices(Now, only Android supported). By using Game loop, no test script required, it will run all the steps in your test App like a real user. This guide will show you how to run a Game Loop test and get your analysis report in WeTest Console.

WeTest offers running single or multiple loops in a test. A loop is a full process from App launch to exit. Game loops can be used to:

  • Launch and Run your App as a real user.
  • Run your App against multiple real devices to figure out compatibility issues.
  • Run a technical test such as game engine upgrade or shader compile.

Preparing for your Test

To run your first test, you have to configure your App in build settings. For Android, modify your Manifest.xml.

  1. Add WeTest new intent filter to your activity in manifest file
<activity android:name=".MainActivity">
         <action android:name="com.wetest.intent.action.GAME_LOOP"/>
         <category android:name="android.intent.category.DEFAULT"/>
         <data android:mimeType="application/javascript"/>
			... (other intent filters here)

It will let the platform to launch your App with a target intent.

  1. Integrate the test loop code in ( onCreate recommended), just add the following lines:

    Intent launchIntent = getIntent();
    if(launchIntent.getAction().equals("com.wetest.intent.action.GAME_LOOP")) {
         int scenario = launchIntent.getIntExtra("scenario", 0);
         // Code to handle your game loop here

This allows you to check the launch intent. You can also add this code in any activity.

finish() will exit your app after each Game Loop. Based on your logic and framework, test will automatically launch the next loop.

Run your first Game Loop test

After you have configured your app for Game Loop tests above, now you are able to run the test with your test App. You can choose to run a test on our platform using either the WeTest Console or REST API or CI/CD plugin.

WeTest Console(Web UI)

Step1: Choose or upload your App, only .apk supported
Upload App

Step2: Choose “GameLoop” as testing Framework
Choose GameLoop

Step3: Choose Target Real Devices
Choose Target

Step4: Submit your test
Submit Test

Step5: View Test Analysis
View Test Analysis

Advanced Settings

Game Loop offers several advanced settings that make your test more efficient, including the ability to set time-out period, multiple loops, and labels to organize your loops.

Write data in log file

You can write your any log to a specific file in the launchIntent.getData() method. After the test finished, you can find the log file in Test Analysis

Using this sample to check your output in

Intent launchIntent = getIntent();
Uri logFile = launchIntent.getData();
if (logFile != null) {
    Log.i(TAG, "Log file " + logFile.getEncodedPath());
    // ...

Output file example

Ouput file is used to show test result and details. The extension of output is .Json, however, you can write any content in your log file. Json format is recommended.

  "name": "test name",
  "start_timestamp": 0, // Timestamp of the test start (in us).
  "driver_info": "...",
  /.../, // custom fields

Run Multiple Game Loops

WeTest offers running multiple Game Loop in a single test. A game loop means a complete process of running you App from launch to exit. Here is a good example. If you are testing a game adventure with 10 levels, it might be an efficent way to run each level instead of running an entire loop that completes all levels at once. If your test completes the level 8 successfully and crashes at the level 9, you can easily find out there are something wrong in level 9 and test reproduce bugs.

For exmaple, your want to test a game adventure with 10 levels.

  1. Add the following code to your app’s manifest, inside the <application> element:
    android:value="10" />

The value can specify an integer from 1 to 1024.

  1. If you have set game loop test for 10 times like above, each loop is launched in sequence after the preceding loop completes which means your App will launch 10 times. You can handle each loop to run different logic.
   // Get Loop id  
	 public static int getLoopId(Intent launchIntent) {
        if (launchIntent.getAction().equals("com.wetest.intent.action.GAME_LOOP")) {
            return launchIntent.getIntExtra("scenario", 0);
        return -1;

    // Game Loop Test depend on loop id
    public static boolean startTest(Context context, Intent launchIntent) {
        int loop_id = getLoopId(launchIntent);
        if (loop_id < 0) {
            return false;

        // define what to do in specific loop
        switch (loop_id) {
            case 0: {
                //TODO: handle loop 0
            case 1: {
                //TODO: handle loop 1
            case 2: {
                //TODO: handle loop 2
            case 10: {
                //TODO: handle loop 10
        return true;
  1. Scenarios

    If you’re running a test with the WeTest Console, input a list or a range of loop numbers in the Scenarios field to run only the specific loops. By default, Test Lab will run all available loops. Example, if you enter 1,2,5-6 in Scenario field, the test will only run Loop 1,2,5,6

        android:value="10" />
  2. Labels

    The feature of Labels will help your team easily launch a target set of game loops. For example, if you only want to test App compatibility, you can create your own label or use the predefined labels to run part of game loops.

  • com.wetest.automation.gameloops.user_experience: For loops used to figure out any issues related to user experience.
  • com.wetest.automation.gameloops.gpu_compatibility: For loops used to test GPU-related issues.
  • com.wetest.automation.gameloops.compatibility: For loops used to test compatibility issues including Crash, ANR.
  • com.wetest.automation.gameloops.performance: For loops used to test the performance on target device.

By using Labels, you have to add the following code in your build settings(Manifest.xml). You can create your own label name which just make sense to your team. Value means which loops the label contains.

    android:value="1,3-5" />

For example,

    android:value="1,3-5" />

If you input “Compatibility” in the Labels field when submitting test in WeTest Console, the test will only run test under “Compatibility” which means Loop1,2,3,4,5 will be executed.

Parallel Session

According to your subscription plan, you are able to run an automated test against multiple devices at the same time. It will help you reduce the run time of your test. During your free trial, the number of parallel tests is limited to 5. If you intend to trigger more devices than 5, they will be queued.


  • Device Run time-out period

    • The timeout of the each device running in target test. The default value is 10 minutes.
      Device Timeout
  • Test Run time-out period

    • The timeout of the target test. The default value is 30 minutes.
      Test Timeout

WeTest Game Loop also supports Firebase, if you are migrating from Google Firebase, you can directly upload and run you App without modify any code or settings(Manifest.xml).