The Challenge

BYJU’s app is built with Unity, which makes automation tricky. Appium cannot detect elements inside of a Unity application like BYJU’s, making automation testing difficult. BYJU’s developers found that they had to conduct all tests manually, which slowed releases and created room for human error.

The Solution

HeadSpin’s Mobile Performance Platform allowed BYJU’s to implement precise automation tests across new builds of their app. These automations were set up two different ways.

Option 1: Find elements using images

There are two ways for a developer to address the challenge of automating a Unity application. One option uses images to be identified by Appium. Appium can then click/perform automation using these images.

As with almost any approach to programming, using images to find elements has benefits and drawbacks. Leveraging images is not a one-size-fits-all approach that will work in all circumstances for Unity Automation. 

 

We recommend using  in cases of automating tests for game load or app load. 

 

Pros

  • Quick development of automation script 
  • Doesn’t require any change to code
  • Can be used for both iOS and Android phones

Cons

  • UI changes (like logo or color changes) may affect the script
  • Image resolution is based on screenshots, which can lead to problems on devices with low resolution
  • Screenshots taken on one device may not work on another (To some extent, these two issues can be controlled using tolerance.)
  • Complex activities in the application (like clicking on a moving object) can create issues

Option 2: Automation using AltUnityTester

When using images proves to be problematic, developers should consider leveraging an automation helper to address the challenge — as the main objective of any automation helper is to give the object information at run time. The easiest way to fix this problem is by embedding a server. By adding a package like AltUnityTester to Unity, Appium can find objects at run time.

 

EXECUTING AUTOMATION TESTING WITH HEADSPIN

Using the above approaches, BYJU'S was able to set up and remotely execute Unity Automation tests and debug scripts. BYJU’s originally created Automation test and debug scripts to run locally. However, HeadSpin allowed developers to run the same set of scripts on real devices located in Delhi — from the comfort of BYJU’s Bangalor development office. 

The debug application were installed using Headspin install APIs. Port forwarding was done from the device to the Delhi host using an `adb forward` command. The debug server inside the application was running on 13000 on the remote device. Socat was used to provide forward requests coming from 14000 to 13000 as `localhost`. NOTE: In the example below, the tokens and IDs used in BYJU’s script have been masked.

 

Sample Code

desired_caps = {}

desired_caps['platformName'] = 'Android'

desired_caps['automationName'] = 'UiAutomator2'

desired_caps['deviceName'] = ‘XXXXXXXX’

desired_caps['udid'] = ‘XXXXXXXXXX’

desired_caps['autoAcceptsAlerts'] = 'true'

desired_caps['newCommandTimeout'] = 300

desired_caps['appPackage'] = "<XXXXXXXX>"

desired_caps['appActivity'] = "<XXXXXXXX>"

driver = webdriver.Remote('https://xxxxx.headspin.io:XXXX/xx/<XXXX>/wd/hub', desired_caps)

altdriver = AltrunUnityDriver(driver,platform="cloud",TCP_IP=’xxxxx.headspin.io', TCP_FWD_PORT=14000, TCP_PORT=14000, requestEnd='#')

altdriver.wait_for_current_scene_to_be('test')

altdriver.wait_for_element('test2').mobile_tap()

 

Conclusion

For an app like BYJU’s, testing can make or break the success of the app. Fast, efficient testing can help developers release higher quality products in a timely manner — which boosts user experience and fuels user adoption. 

 

HeadSpin allowed BYJU’s to turn Remote Unity Automation testing into reality. The move from manual to automated testing allowed BYJU’s to release a better quality, higher performing product. 

 

  • Time to market improved by 15X — going from 5 weeks to only a few days. 
  • Automated testing allowed developers to gain a better, more detailed understanding of app performance than manual testing ever could provide, eliminating bottlenecks and addressing specific user experience issues.

“HeadSpin enabled BYJU’s to turn Remote Unity Automation testing into reality. They were able to test mobile app performance for various locations seamlessly on a remote network, through the network of devices that HeadSpin provided. This saved BYJU's time and effort to release a better quality, higher performing product. Time to market improved by 15X — going from 5 weeks to only a few days.“

Mohd. Irfan

Lead Quality Engineer at BYJU'S

Get started with HeadSpin today

Contact Sales
Start Free Trial