Appium together with AltTester Unity SDK

Snehal Salunke
helpshift-engineering
4 min readMay 5, 2023
Mobile Automated Test with AltTester Unity and Appium

When it comes to mobile automation testing, there are many different choices for a test tool. One popular option is Appium, an open-source project which enables running automated tests on both Android and iOS devices.

Whereas AltTester Unity SDK is a free, open-source asset. Its main goal is to enable UI test automation for Unity applications, by instrumenting games to get access and programmatically control the Unity objects.

Appium and AltTester Unity SDK can be used together to create a comprehensive and effective automation solution for testing Unity applications on mobile devices.

What is AltTester Unity SDK?

  • AltTester Unity SDK is an open-source UI-driven test automation tool which helps you find objects in your game and interacts with them using tests written in supported languages like C#, Python or Java.
  • It allows automating interactions with Unity game objects, such as clicking buttons, setting values in unity, and asserting expected behaviour.
  • It provides cross-platform support which allows you to automate the testing of Unity applications on Android and iOS platforms as well as on PCs
  • It can be integrated with Appium to interact with native elements

How AltTester Unity SDK works?

AltTester Unity SDK framework contains the following modules:

  • AltDriver
  • AltTester Package (Unity)
AltTester Unity SDK

AltTester Unity SDK is used to instrument your Unity App to expose access to all the objects in the Unity hierarchy. The instrumented Unity App opens up a Web socket connection on the device and waits for an AltDriver to connect after starting the application.

AltDriver module is used to connect to the instrumented Unity App, access all the Unity objects and interact with them to simulate any kind of device input through tests written in C#, Java or Python.

AltTester Package contains the AltTester Editor window which is the GUI used for instrumenting a Unity game and running C# tests directly from Unity Editor.

Why use Appium together with AltTester Unity SDK?

  • Cross-platform testing: Combined with Appium, which is a widely used cross-platform mobile automation framework, we can create automated tests for Unity applications on both Android and iOS devices.
  • Native and Unity interactions: Appium is designed for automating native mobile applications, while AltTester Unity SDK is specifically tailored for automating Unity applications.
    By using Appium in combination with AltTester Unity SDK, we can automate interactions not only with the native UI elements of our mobile app but also with the Unity game objects and UI elements within our Unity application.
  • Comprehensive testing coverage: This allows for comprehensive end-to-end testing coverage of the Unity application, including interactions between native and Unity components.
  • Flexibility and Scalability: Both these tools provide flexibility and scalability in automation testing. Appium supports multiple programming languages, including Java, Ruby, Python, and C#, allowing you to choose the language that best fits your team’s expertise. AltTester Unity SDK provides C# scripts and Unity components for automating Unity applications, which can be easily integrated into your existing Unity projects.
  • Easy setup and configuration: AltTester Unity SDK provides easy setup and configuration within the Unity environment, with clear documentation and examples available on developer’s guide.

How to integrate AltTester and instrument your game?

  1. Open the AltTester Editor window from Unity Editor -> AltTester -> AltTester Editor
  2. In the Build Settings section set AltTester Port to 13000
  3. In the Scene Manager section select the scenes you want to include in your build
  4. In the Platform section select desired platform and set the path to where you want to save the build
  5. Press “Build Only” to instrument the game or “Build & Run” to start your instrumented game after the build succeeded
  6. Check the console to see if the build was successful.

To integrate and to create instrumented app, you can follow below video as well.

Integration with AltTester

How to integrate AltTester in Appium?

  1. Integrate AltTester Unity SDK dependency in POM.xml file of your Appium framework.
<!-- https://mvnrepository.com/artifact/com.altom/altunitytester-java-client -->
<dependency>
<groupId>com.alttester</groupId>
<artifactId>alttester</artifactId>
<version>1.8.0</version>
</dependency>

2. Add the created instrumented app in the Capabilities files for Android and iOS platforms.

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "WKZLMJLB7L8TR8SW");
capabilities.setCapability("platformName", "Android/iOS");
capabilities.setCapability("appPackage", "com.example.unity");
capabilities.setCapability("appActivity", "com.unity3d.player.UnityPlayerActivity");
capabilities.setCapability("app", "#path_to_apk/ios_app_file");

3. Run the test suite written in Appium framework

The use of AltUnityTester and Appium together can be a powerful combination for mobile app testing. However, it is important to note that using these tools together may require some technical expertise and configuration. Additionally, the effectiveness of the combination will depend on the specific requirements of the testing project and the quality of the test scripts and scenarios developed.

Thanks to Pankaj Dusane for helping in all the work required in integrating AltTester with Appium.

--

--