Running Parallel Tests with Appium¶
First, you will need to enable and connect your devices to adb. To do so, please refer to Connect to ADB.
Start appium server¶
Since Appium 1.7, it’s easy to do parallel testing using only one appium server. Before that, we had to start N appium servers in order to test N devices in parallel.
So let’s start an Appium server, simply using the basic command:
Write your tests script in Python¶
We will use Python throughout this tutorial but you can use a different language if you prefer.
We’ve chosen to use Pytest as our test framework. It has several useful plugins like:
xdist: for running tests in parallel.
rerunfailures: for rerunning failed tests an arbitrary number of times to reduce build failures due to flaky tests
Here is a simple python script, please replace
[instanceX_ip] values by the IPs of your instances:
For convenience, we will call this python script
How to run Python tests in parallel¶
If we run the python script as follows:
pytest will execute tests on one device at a time. However, in order to have results as soon as possible, we need to execute all the tests at the same time. To do that, we can take advantage of the
pytest-xdist plugin and run the following command :
-n: number of worker processes you want to use. Here we start the suite with 3 processes.
How to run Python tests in parallel with Java¶
A Riddle application is used for testing. It runs 2 same tests on 2 devices. The application needs to be already installed on the device but you can change those 2 lines to
capabilities.setCapability(MobileCapabilityType.APP, $PWD/Apps/appriddle.apk); where
$PWD is the absolute path where your project is located.
Configuring devices used for testing is there. Replace the
udid by the ADB serial number of the device.
Run the tests :
- Start the devices and connect it to your computer/CI server
Start appium server
To see an example of: