![](https://assets.wetest.net/wetest-web-net/pro/img/030b28eb.png)
![](https://assets.wetest.net/wetest-web-net/pro/img/030b28eb.png)
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:
To run your first test, you have to configure your App in build settings. For Android, modify your Manifest.xml.
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="com.wetest.intent.action.GAME_LOOP"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/javascript"/>
</intent-filter>
<intent-filter>
... (other intent filters here)
</intent-filter>
</activity>
It will let the platform to launch your App with a target intent.
Integrate the test loop code in MainActivity.java ( 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
finish();
}
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.
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.
Step1: Choose or upload your App, only .apk supported
Step2: Choose “GameLoop” as testing Framework
Step3: Choose Target Real Devices
Step4: Submit your test
Step5: View Test Analysis
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.
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 MainActivity.java.
Intent launchIntent = getIntent();
Uri logFile = launchIntent.getData();
if (logFile != null) {
Log.i(TAG, "Log file " + logFile.getEncodedPath());
// ...
}
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
}
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.
<application>
element:<meta-data
android:name="com.wetest.automation.gameloops"
android:value="10" />
The value can specify an integer from 1 to 1024.
// 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
break;
}
case 1: {
//TODO: handle loop 1
break;
}
case 2: {
//TODO: handle loop 2
break;
}
......
case 10: {
//TODO: handle loop 10
break;
}
default:
}
finish();
return true;
}
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
<meta-data
android:name="com.wetest.automation.gameloops"
android:value="10" />
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.
<meta-data
android:name="com.wetest.automation.gameloops.LABEL_NAME"
android:value="1,3-5" />
For example,
<meta-data
android:name="com.wetest.automation.gameloops.Compatibility"
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.
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.
Device Run time-out period
Test Run time-out period
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).