Summary of APP UI automation testing framework, actual combat and source code of various projects are waiting for you

Table of contents

Development language selection

UI testing framework selection

Unit testing framework selection

Test environment construction

script writing

Jenkins integration


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

APP automation testing: A must-see tutorial for zero-basic APP automation testing, teaching you how to automate APP from zero to one, various projects and source codes are waiting for you_哔哩哔哩_bilibili APP automation testing zero-basics must-see tutorial, from Zero-to-one teaches you how to automate APP. Various projects and source codes are waiting for you to get a total of 15 videos, including: 1. APP automation [environment construction and App automation testing principles], 2. APP automation [install appium server], 3. APP automation [Desired Capabilities-Appium automation configuration items], etc., more exciting videos of UP master, please pay attention to UP account. https://www.bilibili.com/video/BV1yh4y1o7pc/?spm_id_from=333.999.0.0

 

UI testing framework selection

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

Appius

  • 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 

Airtest

  • Developed by Netease, 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

choose frame

Choose the appropriate frame according to the actual situation.

Netease Airtest 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)

Unit testing framework selection

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

It is strongly recommended to use pytest here, which is powerful and easy to use. The official documentation is in English. For Chinese, please refer to the Pytest manual.

 APP automation testing: A must-see tutorial for zero-basic APP automation testing, teaching you how to automate APP from zero to one, various projects and source codes are waiting for you_哔哩哔哩_bilibili APP automation testing zero-basics must-see tutorial, from Zero-to-one teaches you how to automate APP. Various projects and source codes are waiting for you to get a total of 15 videos, including: 1. APP automation [environment construction and App automation testing principles], 2. APP automation [install appium server], 3. APP automation [Desired Capabilities-Appium automation configuration items], etc., more exciting videos of UP master, please pay attention to UP account. https://www.bilibili.com/video/BV1yh4y1o7pc/?spm_id_from=333.999.0.0

 

Test environment construction

Test computer selection

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

Test phone selection

At the beginning of the test script debugging, you can choose an emulator, and the Android emulator can choose Ye Shen Simulator, Raiden, and mumu.

 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 the real user usage scenario.

development language environment

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

UI automation test framework environment construction

Please refer to other blogs to build Appium under Windows environment. Building Appium under Mac is a bit more complicated, and I will write blogs to share later.

If you choose the Airtest framework, please refer to the official website.

script writing

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.

Determine directory structure

It is recommended to use the Page Object design pattern to develop APP UI automation test projects, please refer to the blog Page Object design pattern.

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, please refer to the blog unittest unit test framework. 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.

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.

Summarize

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.

APP automation testing: A must-see tutorial for zero-basic APP automation testing, teaching you how to automate APP from zero to one, various projects and source codes are waiting for you_哔哩哔哩_bilibili APP automation testing zero-basics must-see tutorial, from Zero-to-one teaches you how to automate APP. Various projects and source codes are waiting for you to get a total of 15 videos, including: 1. APP automation [environment construction and App automation testing principles], 2. APP automation [install appium server], 3. APP automation [Desired Capabilities-Appium automation configuration items], etc., more exciting videos of UP master, please pay attention to UP account. https://www.bilibili.com/video/BV1yh4y1o7pc/?spm_id_from=333.999.0.0

 

Guess you like

Origin blog.csdn.net/MXB1220/article/details/130892825