Mobile Testing with TestProject in CI/CD
TestProject is a free, end-to-end test automation platform for web, mobile, and APIs. In this article, I’m going to show you, essentially, how to perform mobile testing with TestProject. More specifically, I’m going to be showing you how to run automated tests in a mobile app on Android, integrated with Jenkins.
Although TestProject allows you to automate testing for both Android and iOS applications from Windows, we will focus on Android applications. It’s worth clarifying that you typically need a Mac to automate tests on iOS, but now you only need to have a TestProject agent and an active Apple developer account. Check out this doc for the steps to configure it.
What Do You Need?
To perform mobile testing with TestProject, you will need to create a free account on the TestProject site and then install a TestProject agent on your computer. Then, you must connect your device to it using a USB cable and you’ll be ready to record the steps of your test with the tools’ recorder. At the end of the recording, you will have a script that you can edit and run.
In TestProject, you can work with both emulators and real devices. If you want to work with an emulator, it’s not necessary to carry out the following steps, just have the emulator open and TestProject will recognize it as an agent. If you want to work with a real Android device, you must first prepare it as follows:
- Make sure you have your mobile device in developer mode. For this, you must go to Settings (for Android 8.0 and higher) and then select About the phone. Tap 7 times on the Build number to enable developer mode.
- You can find an option in the settings called developer options. Here you will need to enable the option, USB debugging.
- If your device is Xiaomi, you need to enable the options, USB debugging(security option) and Install via USB.
- Have your device and USB cable ready and connect it to where you installed the TestProject agent. When connected, a pop-up window will appear asking for authorization to use the device with TestProject. After accepting it, you will be able to start creating the test.
How to Create a Mobile Test in TestProject?
To create a test, you must click on New Test and choose the option, Mobile test.
Then you must write a name and description for the test. By selecting Next, choose which platform you will use (Android or iOS) and which application you are going to test. If this is the first time that you create a test, you won’t see any applications in the list so you will have to click on Add a new application for testing.
Add an Application
There are several ways to add an application. The simplest is making sure that your device is connected and the agent is running, then TestProject will show you all the applications available on the device and you can select one. If you want, you can upload an APK or do it manually.
Once you have chosen the application and assigned a name to it, you must click on Finish.
Recording a Test
Now that you’ve created a test and specified which application to use, you are ready to create your test steps. You can create steps manually if you wish as well as use the tool’s recorder.
If you choose the option to record, an emulator will be displayed that will show the screen of your device and the steps that will be recorded.
To create steps, you must interact with the application emulator and each action will be recorded as a step.
This is what a script looks like in TestProject:
Each of the steps can be removed, duplicated, and disabled. Steps can be created manually by clicking on the “+” button or by using the recording tool.
When creating manual steps, you have the option of adding a previously created test, an action or an element action.
If you choose the option, Element Action, for each element you will have several selectors that can be ordered by choosing the priority. The selectors available for the web are:
and for mobile:
On the other hand, if you want to add an Action, you have a long list of actions as shown below:
How to Integrate TestProject with Jenkins CI
To integrate TestProject with Jenkins CI, you will need a TestProject account and the Jenkins CI server running. Then you can follow these steps:
- Install the TestProject plugin in Jenkins
- Open the server
- Go to Manage Jenkins → Manage Plugins→ Available
- Search for TestProject Automation Platform Plugin and install it
- Create an API Key in TestProject
- Open the TestProject application and go to Integrations → API
- Create a new API Key and grant it the desired access. API keys can be accessed without restrictions, which means that they can be used in any project or have access to specific projects.
- Once the API key is created, you will need to copy it and go back to the Jenkins server.
- Configure the TestProject plugin in Jenkins and set the newly created key. This is a one-time step.
- In Jenkins, go to Manage Jenkins → Configure System.
- Find the TestProject section, paste your key into the API Key field, and hit Save.
- Create a TestProject Job
- Create a freestyle project.
- Add a new step in the section, Build. Select Run TestProject Job from the drop-down menu.
- Select a Project Id and Job Id from the corresponding menus.
- Hit save.
- Select the newly created project and click on Build now.
- See the results
- Once the execution is complete, you will be able to access the console output where you will have a link to the report in TestProject.
Now that we’ve shown you how to create an automated mobile test and integrate TestProject with Jenkins, let’s go over some of the advantages of TestProject.
Benefits of TestProject
- It’s 100% free
- TestProject comes with a lot of support and resources (blog, forum, Youtube channel, and documentation).
- It offers an online chat to help you out.
- You can perform both tests for Android and iOS from Windows.
- If you want to work with code, when creating a new test, TestProject allows you to upload a .zip, .jar, or .dll file.
- If you choose to use the recorder, the selectors are auto-generated but customizable (they can be modified or you can create new ones).
- When working with web elements, their selectors can vary from the moment you create the tests until you execute them. Thanks to TestProject’s Artificial Intelligence-based functionalities, when a test is re-executed and it cannot find the selector that you indicated, it automatically tries to find the element with another selector.
- In each step of the test, you can add assertions, pauses, conditionals and loops.
- You can perform data-driven testing by parameterizing the test and adding a CSV file from which to take the data.
- You can use regular expressions to extract the value of a field and later work with that value. For example, if you’re working with an application that has a certain stock of a product, you could extract the number of products that are in stock, make a purchase and verify that that number decreased.
- Tests can be modularized, calling from one test to another to improve their maintainability.
- The tests can be grouped in jobs, where different tests can be added, even repeatedly as we can see in the image (the test, Opencart, is there twice).
- At the end you’re able to export the code of your test in Java, C# or Python:
- At the same time, you can generate a manual test in an Excel spreadsheet:
and finally the test document:
Final Thoughts on Mobile Testing with TestProject
The quick setup and ease with which you can automate a mobile test and have it running in Jenkins makes TestProject a great choice to consider when automating. As mentioned before in this proof of concept, we found several benefits that TestProject provides. We hope to be able to make more extensive use of it in the future so that we can share even more of our experiences with you.
Read the Ultimate Guide to Continuous Testing
- Abstracta is recognized with the award “Talent has no Gender” for its work towards gender equality.
- GoodFirms: Abstracta CEO Steers the Company Towards Its Vision to Co-Create World-Class Solutions, Improving People’s Quality of Life
- An End-to-End Guide of Load Testing
- Quality Sense Podcast: Ash Coleman – Diversity, Equity, and Inclusion at Work
- Quality Sense Podcast: Simon Prior – #MakeATester