Summary of APP UI automation testing ideas

First of all, I want to explain that APP automation testing may not be used by many companies, but it is also required by most automation test engineers and senior test engineer job recruitment information. Therefore, in order to get better treatment, we still need to spend time to master it. After all, who It will not be difficult for money. Next, let’s summarize the ideas of APP UI automation testing.

01. Development language selection

Programming languages ​​commonly used for automated testing include: Python, Java, Javascript, Ruby, C#, PHP, etc. Generally, we will choose a programming language we are familiar with to write automated scripts, but for children's shoes with basically zero programming foundation (or children's shoes that focus on automated testing), it is recommended to learn to use Python.

Compared with other languages, Python has the following advantages for automated testing:

  • For beginners, Python syntax is concise, highly readable, and easy to learn

  • There are powerful third-party libraries, making scripting more efficient

  • The Pytest automated testing framework in Python is currently one of the most popular testing frameworks

02. Selection of test framework

After choosing the programming language, we need to choose the UI testing framework. At present, the more mainstream or widely used APP UI automation testing frameworks include Appium, Airtest, etc.

1、Appium

  • Continuous maintenance and open source

  • Appium server supports running on Windows, macOS, Linux

  • Support multiple mainstream programming languages, such as Python, Java, Javascript, Ruby, etc.

  • Support Android, ios, H5 automated testing (integrated UiAutomator, UiAutomation framework)

  • The environment is more complex

2、Air test

  • Developed by Netease (official document), only supports python language

  • Provides a powerful IDE that integrates the two testing frameworks of Airtest and Poco, which is friendly to novices

  • Integrate image recognition-based UI automation testing framework airtest, even if you don't know code, you can write automation scripts

  • Cross-platform, automated testing of Windows, Android and iOS application software

  • Friendly to game testing

  • Airtest and Poco are essentially two third-party libraries of python, and the test environment is not as complicated as Appium

3. Choose a frame

Choose the appropriate frame according to the actual situation. Netease Airtest (Airtest official website) can be preferred in the following situations:

  • No programming basis

  • game testing

  • The test scenario is relatively simple (Appium is relatively cumbersome)

  • Alipay applet automation (bloggers currently use Airtest integrated Poco framework for Alipay applet automation testing)

It is recommended to choose Appium in the following situations:

  • The test scenario is more complicated (for example, batch testing of multiple mobile phones is required)

  • The test scripting language is not Python (Airtest currently only supports Python)

03. Selection of unit testing framework

Different from the UI test framework mentioned above, the unit test framework is used to load test cases, execute test cases, assert, output test results, etc.

Different development languages ​​have their own corresponding unit testing frameworks, such as Java has JUnit, TestNG, Robot, etc., and Python has unittest, pytest, etc. Bloggers mainly use Python for automated testing, so here we only explain the Python unit testing framework.

Python's mainstream unit testing framework:

  • unittest, the unit testing framework that comes with Python

  • pytest, based on unittest development, easy to use, more detailed information, many plug-ins

  • robot framework, a keyword-driven test framework based on Python, has an interface, comes with reports and logs, complete functions, clear and beautiful

Here it is strongly recommended to use pytest, which is powerful and easy to use, the official document is in English, Chinese can refer to the Pytest manual).

04. Test environment construction

1. Selection of test computer
If possible, it is recommended to use a Mac machine for UI automation testing, because ios app ui automation can only be performed on a Mac machine.

2. The test mobile phone
can choose the emulator when debugging the test script at the beginning. The Android emulator can choose Gernymotion and Yeshen emulator. After the development of the entire test project is completed, it is recommended to replace it with a real machine to run the automation script, which is closer to reality. user usage scenarios.

3. Development language environment
It is recommended to install a version above python 3, and the official has stopped updating and maintaining the python2 version.

4. Setting up the UI automation test framework environment For
building Appium in the windows environment, please refer to the appium environment setting. Building Appium under the Mac is a bit more complicated, and will be shared later. If you choose the Airtest framework, please refer to the official website.

05. Scripting

1. Write a test demo
In order to verify whether the entire test environment is successfully built and whether it can run common cases, generally we need to write a simple test script and execute it. If it passes, it means that the entire environment is successfully built.

2. Determine the directory structure
. It is recommended to use the Page Object design pattern to develop the APP UI automation test project.

3. Select test report
Different development languages ​​and different unit test frameworks can choose different test reports. In python, the unittest framework uses HTMLTestRunner or BSTestrunner to generate test reports, and the Pytest framework uses pytest-html to generate reports or customize test reports through allure.

After the above steps are completed, continue to add test cases to the test project.

06. Jenkins integration

After writing the entire app UI automation test project according to the above steps and running it stably for a period of time, you can consider integrating Jenkins.

07. Summary

Summary APP UI automation can use the following implementation methods:

  • python + app + unittest + HTMLTestRunner

  • python + appium + pytest + pytest-html / allure

  • python + Airtest(AirtestIDE)

  • python + Poco + pytest + pytest-html / allure

You can choose according to the actual situation.


In the end, many friends have the idea of ​​learning automated testing. Here I share a video tutorial on automated testing at Station B. You can watch it by yourself:

How to force myself to finish learning automated testing in one month, and then get a job after learning, Xiaobai can also get it at his fingertips, take it away, and allow free prostitution...

Public account fan benefits

  • Get a full set of software testing resources for free

  • Software testing interview question brushing applet is free to use

  • Free use of GPT exclusively for testers

insert image description here

Guess you like

Origin blog.csdn.net/m0_53918927/article/details/132049825