Running some automated tests for multiplayer games can sound like a real challenge for most of us. So we decided to write an article and present how to make the setup to run tests on two devices in parallel.
You’ll see references to AltUnity tester in this article, as we use it in most of our game testing projects. It’s a UI driven test automation tool, that helps you find objects in your game. You can check out this article for more info.
Let’s focus on the initial challenge and get started with testing multiplayer features. See below some steps and an example project.
We chose the tanks reference project sample as it has a multiplayer component where you compete against other opponents in a match. It runs on the following platforms: Windows, Mac, Android and iOS.
Setting up a build with Altunity Tester
The first step is to build the game with AltUnity Tester on the desired platform. We wrote some scripts for two different setups: 2 Android devices and one Android, one iOS device, but you can have any setup. For more information about how to build the game with AltUnity Tester check the documentation.
Now that we have the builds, let’s see how we are going to communicate with the build to perform the actions written in the tests. There are two ways to do that. You can forward the device port to your computer port so that you can connect on localhost. This means that your devices are needed to be connected to your computer. The second option is to connect directly to the device by giving the device’s IP. This means that the devices need to be in the same network with your computer. More information about this can be found here.
We wrote a simple test to see that two devices can play a match together. We start by sending the commands to the players to create and join the server. Once the “players” are in the game we send commands to find each other and to shoot until one of the players wins.
Check out the video below for more info about the setup and test flow:
In our repository, you will find more shell scripts that will install the game on the device, forward the port and run the tests mentioned above which also include the test we discussed above. See more information in the ReadMe file.
- We encountered some issues with the sample when building for Android. Some of the packages are deprecated. To solve the problem, we removed all the deprecated references from the project. The main feature that we are interested in was not affected so it wasn’t a problem for us. On our git repository, you can find the Unity project with the deprecated part removed.
- You might want to change the services to your organization so other users don’t influence your tests. Check this video to see how.
If you have any questions write to us on gitter or if you discover an issue please write an issue and we will try to fix it as soon as possible.