Testing Unity-built projects targeting the Android platform is a straightforward process, and can easily be added to the build-verification pipeline with a few simple steps.
This article assumes you have already installed the GameDriver agent into your Unity project, and have at least a basic test running against the Unity editor.
Unity Project Settings
Make sure your project is targeting iOS under the Unity editor > File > Build Settings, and that your project supports the following under Player Settings > Other Settings:
The Company Name, Product Name, and Version should all be filled as these will be used to populate additional fields for the player build.
Next, verify the package name and version appear as expected and that the Minimum and Target API levels are in line with supported devices and APIs required for your project. Again, refer to the Unity documentation for more details on the API Compatibility Level required by your project.
The GameDriver agent requires:
- .NET 4.x API compatibility level
- ARM64 Target Architecture
Installing the app on your device or emulator
Once you build your project, you will need to install the resulting .apk file on your device or emulator before you can run your test. You can then connect to the device via Unity, Android Studio, or command-line. At a high level, the process is as follows:
- Build your APK via Unity
- Connect to the device and install the APK.
- To do this, you will use the Android Debug Bridge (ADB) that ships with the Android Studio. For a physical device, you first need to put the device into Developer mode and enable debugging over USB or Wifi. For detailed steps, please refer to the ADB documentation.
- You can also connect to the device/emulator automatically during the build process, by selecting it in the Unity Build Settings dialog, as shown below.
- Before running your test you will need to run the following command to forward GameDriver API traffic to the connected device/emulator, replacing "19734" with the port you are using in the GameDriver agent configuration in Unity. Be sure to add android_sdk/platform-tools to your PATH environment variable first.
- adb forward tcp:19734 tcp:19734
- Run your tests!
- Once your test has been completed, you will need to run the following command to remove the TCP port forwarding via ADB in order to continue testing via the editor.
- adb forward --remove tcp:19734