Welcome to this Cerberus Testing step-by-step tutorial for testing mobile applications. This guide will help you understand the test automation workflow and good practices supported by Cerberus Testing.
At the end of this article, you will be able to automate mobile application tests for Android and iOS. You will learn how to configure your device, create and execute the test case. We will perform the test of an Android application using Browserstack.
As Cerberus Testing is leveraging the Appium library, you can use this tutorial to implement your own test. If you are new to Cerberus Testing, we recommend that you start by having a look at our GitHub page, website and overview video.
First of all, make sure to have the following elements ready to successfully complete this tutorial:
- A Cerberus Testing instance in version 4.x, self-hosted or SaaS.
- A user account granted with a “Test” role.
- A test environment (by default “QA” and “UAT” are set up).
- A Local or Remote Mobile Device available through the Appium interface.
In addition, if you decided to implement your own Test, you need to secure the following points:
- Access to the application under test, as well as to the mobile application package (.apk or .ipa)) in the device. Make sure you have a user account if you need to log in
- Define the Test action and controls you want to perform and verify if they are compatible with the Appium library
If you have any questions on those prerequisites, have a look at our documentation, videos or contact your administrator. Feel free to interact with the community on our slack channel or submit a GitHub issue.
Step 1 — Setup the Application and Test Robot
This section describes the initial setup and integration to enable the mobile test automation. First, we have to upload the mobile application on the device we want to test. Then, we are able to configure the robot to interact with the device under test. Lastly, we define the application under test environments to reference in our test cases.
1.1 Upload Your Mobile Application
After the successful upload, you will reach the screen below to access the various capabilities required.
1.2 Create The Testing Robot
Our application being ready on the device, we can now configure the Test Robot inside Cerberus Testing.
Here, the following pop-up will appear with the necessary information to describe your robot :
- Type: Choose either IPA for iOS devices, or APK for an Android one.
- Platform: Choose the correct one depending on your first option.
You can then add the required capabilities from the previous step.
And finally configure the testing hub integration parameters.
1.3 Create The Application
Finally, the last step is to create the application under test. This will enable us to reuse the same application definition across various tests, simplifying their maintenance. It involves defining the application name, description, typology and available environments.
The following pop-up will appear with the necessary information to describe your application :
- Type: Select the same mobile application typology as previously.
- System: Select to which system this application belongs to.
You can now move to the tab “Environments” where we will configure the test context. Namely, the test environment (QA, UAT), country and host. The host must contain the id of your device under test. The format is “bs:<id>” in our case.
You can configure as many environments as you desire, combining the test environments or countries parameters. They must represent different test contexts you can opt for your test execution.
Step 2 — Create The Test Case
We will now build our test case to be run against the application we just created. In a similar way, we will access the required menu, define our test case content and share tips related to the test creation process.
Click on “Create Test Case” to display the creation pop-up, that we will fill with the required information :
- Test Folder: Select in which folder you want to keep your test cases. Here choose “Demo”. The folders can be managed in the “Test / Test Folder” page.
- Testcase ID: Enter your custom ID or leave the default generated one.
- Test case short description : Enter one-line description, usually in a use-case format “As a <user>, I want to do <use-case> and verify <controls>”
- Application: Select the application under test, in our case “SampleBSAPK”
- Status: Choose the implementation state of your test case, in our example we set it to “STANDBY”. For information, the status can be used as test execution criteria and a dashboard is available on the homepage.
- Type: Select “AUTOMATED” to confirm it is an automated test. You can have manual or private tests but we will not cover them here.
- Priority: Usually from 1 to 5, it can help you to prioritize your test implementation, reporting or go-nogo criteria for a campaign report. Leave it to “0 – No Priority defined”.
- Detailed description (optional): Use this box to enter your relevant use-case and test information. As the format is in HTML, you can copy rich content.
The other tabs are not necessary for now. A specific note if you are creating your own test and want to run it in the ”PROD” test environment – you will need to activate this in the tab “Execution Settings” by checking the corresponding box.
Clicking on “Create”, you will confirm the test case creation. If you accept the default test case creation, a default Step will be created. In our case, we will follow a brand new creation process.
Step 3 — Define The Step, Action and Control
We can now configure the test case content using the low code library: Step, Action and Control. A Step is a collection of Action and Control for the main stages of your test. With a good design of those elements, you will be able to reuse them across tests to improve your test maintainability.
3.1 Add the Test Case Step
We can now add a Step via the “Add Step” button and enter the corresponding description. Use clear descriptions in order to have a good test readability with improved maintainability and reusability.
3.2 Add the Test Case Action and Controls
In this step we will detail the various actions and controls that should be performed during the tests. The commands are executed in their order of appearance.
We listed below the parameters that you can use:
- Open the mobile application
- Action openApplication: Open the application set in the Application definition.
- Please note that you need to start your mobile application test with one of the “open” actions for Cerberus Testing to know where to start.
- Take a screenshot after application opening
- Control takescreenshot: Will take a full screen screenshot (defined it for the sake of demonstration). However, they can be taken automatically at every action or only for errors for example.
- Perform various compute operations
- Action click: Click on the recognized element.
- Element path xpath=//input[@name=’btnK’]
- Verify the search results
- Control verifyElementTextEqual: In this case, we will verify if the result of our operation is as expected in the result area. A lot of other controls are available and described in the documentation.
- Close the mobile application
- Action closeApplication: Close the application to end the session with the robot acting as the interface between your test and the device.
- This will avoid the test to remain pending and liberate the session.
We confirm the changes by clicking on the “Save Test Case” button in the top right corner.
Step 4 — Run The Test Case
We are now ready to execute our Test Case! Navigate to the Run page by going to “Run / Run Test Case”. By default, the other options are not available until you run the test once in a specific environment.
4.1 Launch the Test via the Run Test Page
Here, the Test Case is selected by default so we can define the execution parameters scrolling down on the page.
Next, confirm the following parameters :
- Environment: Select one or more environments where the Test Case should be executed. In our case, pick “PROD”.
- Country: Check one or more countries where you would like to run the Test Case. One more time, the country you select must be defined in the Application. Pick “UK”.
- Robot Settings: Define the mobile app hub where the Test Case will be executed upon. In addition, you can integrate with other remote testing farms such as LambdaTest, Kobiton, Saucelabs among others.
- Execution Settings: Mainly related to the traceability levels for the test, test infrastructure and queuing mechanisms (retry, priority, …).
Launch the Test Case and see it running live by clicking on “Run TestCase (and See Result)”.
4.2 Follow the Test Case Execution
You will see this page appearing after the test launch.
If you encounter an issue at this stage, we listed here the common themes:
- Verify your Application definition, especially for the test environment and country. If you encounter a message related to those parameters this is probably the problem.
- Verify your Test Case activated Environment. If you cannot launch your test in a Production environment you will need to explicitly activate it in the Test Case Header.
- Verify your Robot is correctly running and accessible on the ports you configured. You can manage them on the “Run/Robots” page.
Step 5 — Analyze The Test Case Report
It is now time to analyze the result of our Test Case execution! Once your Test Case is finished, the progress bar on the top will display your Test Status. The main ones are OK or KO, you can access more detailed information in the Cerberus Testing Documentation on Execution Status.
We described here the various tabs and their corresponding usage :
- Steps: History of all your Test Case Step, Action and Control performed, with executed data and links to the various screenshots, for instance.
- Properties: Find here all the Properties used for your test. As we did not define one here, this tab is empty.
- Execution Details: Traceability related to the Test Case execution including start and end times, status and ID. It is from this tab that you can open a ticket to an external platform if it is configured.
- Environment: Describes the Test Case environment context.
- Robot: Traceability of your Robot test infrastructure and browsers.
- Traceability: Contains the changes made to the execution if any.
Expanding Your Mobile Testing Automation
By now you should have been able to run the example we described or even a test case of yours. We hope this tutorial was helpful for you to understand the main stages involved to automate your mobile testing.
You can now expand your testing by creating reusable step libraries, duplicating or composing your test case and enriching them with specific properties. A good practice is to invest in your Test Design and modules in order to have fast, reliable and maintainable tests.
Scaling your test automation will be supported by the other capabilities offered by Cerberus Testing. You can for example easily parallelize your tests across various browsers adding a robot in your existing definition.
There is much more to explore that we hope to share with you in the next articles. Feel free to react, engage in the comments, or on our social media. In the meanwhile, Happy Testing!