It is said that this is the most comprehensive, a summary of App automation testing ideas, implemented from 0 to 1...


Preface

1. Programming language selection

Programming languages ​​commonly used for automated testing include: Python, Java, Javascript, Ruby, C#, PHP, etc. Generally, we will choose a programming language that we are familiar with to write automated scripts, but for children who have basically zero programming foundation (or children who 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 has a concise syntax, is highly readable, and is easy to learn.
There are powerful third-party libraries that make scripting more efficient.
The Pytest automated testing framework in Python is one of the most popular testing frameworks currently.

2. UI testing framework selection

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

Appium
is open source;
Appium server supports running on Windows, macOS, and Linux;
supports multiple mainstream programming languages, such as Python, Java, Javascript, Ruby, etc.;
supports Android, ios, H5 automated testing (integrated UiAutomator, UiAutomation framework);
environment The construction is more complicated;

Airtest
is developed by NetEase (official document) and only supports python language;
it provides a powerful IDE integrating Airtest and Poco testing frameworks, which is very friendly to novices;
it integrates the UI automation testing framework airtest based on image recognition, even if you don't understand the code, you can Write automated scripts;
cross-platform, can conduct automated testing of Windows, Android and iOS application software;
more friendly to game testing;
Airtest and Poco are essentially two third-party libraries for Python, and the test environment is not as complicated as Appium;

3. Choose a frame

Choose an appropriate framework based on the actual situation.
You can give priority to NetEase's Airtest (Airtest official website) in the following situations:
No programming foundation
Game testing
The test scenario is relatively simple (Appium is relatively bulky)

Alipay mini program automation (the blogger currently uses the Poco framework integrated with Airtest for automated testing of the Alipay mini program)

It is recommended to choose Appium in the following situations:
the test scenario is relatively complex (such as batch testing on multiple mobile phones)
and the test script language is not Python (Airtest currently only supports Python)

4. Unit testing framework selection

Different from the UI testing framework mentioned above, the unit testing 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 JUnit, TestNG, Robot, etc. for Java, and unittest, pytest, etc. for Python. Bloggers mainly use Python for automated testing, so here we only explain the Python unit testing framework.

Python's mainstream unit testing framework:
unittest, Python's own unit testing framework;
pytest, developed based on unittest, is easy to use, has more detailed information, and has many plug-ins;
robot framework, a keyword-driven testing framework based on Python, has an interface. Comes with reports and logs, fully functional, 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 user manual.

5. Test environment setup

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 mobile phone selection:
You can choose an emulator when debugging the test script at the beginning, and the Android emulator can be selected; Gernymotion, Yeshen emulator, please refer to the blog Android emulator usage for details;

After the development of the entire test project is completed, it is recommended to switch to a real machine to run the automated script, which will be closer to the real user usage scenario.

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

UI automation testing framework environment construction:
To build Appium in the windows environment, please refer to the blog appium environment construction. Building Appium under Mac is a little more complicated. I will continue to share it later.

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

6. Script writing

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

Determine the 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 reports:
Different development languages ​​and different unit testing frameworks can use 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.

7. Jenkins integration

After writing the entire app UI automated test project according to the above steps, and running it stably for a period of time, you can consider integrating Jenkins. Please refer to the blog Jenkins Integration Appium Automated Testing (Windows) or add a new Mac node to remote Jenkins.

8. Summary

To summarize, APP UI automation can be implemented in the following ways:
python + appium + unittest + HTMLTestRunner;
python + appium + pytest + pytest-html/allure;
python + Airtest (AirtestIDE);
python + Poco + pytest + pytest-html/allure ;

The following is the most comprehensive software testing engineer learning knowledge architecture system diagram in 2023 that I compiled.

1. Python programming from entry to proficiency

Please add image description

2. Practical implementation of interface automation projects

Please add image description

3. Web automation project actual combat

Please add image description

4. Practical implementation of App automation project

Please add image description

5. Resumes of first-tier manufacturers

Please add image description

6. Test and develop DevOps system

Please add image description

7. Commonly used automated testing tools

Please add image description

8. JMeter performance test

Please add image description

9. Summary (little surprise at the end)

Have courage, chase your dreams, and struggle is the journey to embrace success. No matter how hard it is, keep working hard and let your talents and wisdom bloom. Believe in your own strength, go beyond your limits, create a brilliant life, and make every day a brilliant picture of struggle!

Persistent pursuit, fearlessness of hardships, and struggle are the pen and ink that write glory. Bravely overcome difficulties and sharpen your willpower. Only by continuous efforts can you create your own brilliant life.

Forge ahead, keep dreaming, and struggle is the key to expanding infinite possibilities. Stick to your original aspirations and climb to the top. Only by moving forward bravely can you write your own glorious chapter. Believe in your own strength, strengthen your beliefs, unleash your talents, and create a dazzling life!

Guess you like

Origin blog.csdn.net/m0_60054525/article/details/132084831