How to build a company's automated testing framework from scratch?

The automated testing framework built should include three categories : API testing, UI testing, and APP testing . The above three categories can actually be simplified into two categories , namely:

1) Build the interface automation test framework
2) Build the UI automation test framework.

No problem, arrange , and teach you how to build the above two types of automated testing frameworks.

Back to this topic, some of the testers who encountered this question may still be engaged in "manual testing", or some are just getting started with self-study testing. In order to give this type of readers a sense of gain, I split the question into the following 4 parts:

1. Why build an automated test framework
2. Introduction to how to build an API interface test framework
3. Introduction to how to build a UI automation test framework
4. E-book recommendation for an automated test framework

Alright, hold on to the armrests, and then we'll start the formal introduction.

1. Why build an automated testing framework

If testing is divided according to whether it is manual, it can be divided into "manual testing" and "automated testing".

"Manual testing" is the use of human to conduct functional testing. Compared with automated testing, the execution efficiency is slower, and exploratory testing and divergent testing can be performed.

"Automated testing" mainly uses the developed software testing tools, scripts, etc. to replace manual functional testing. Compared with "manual testing", it not only liberates manpower, but also has good operability, repeatability and high efficiency.

Specifically, the advantages of "automated testing" are as follows:

(1) Automated testing has the characteristics of consistency and repeatability, and the testing is more objective, which improves the accuracy, precision and trustworthiness of software testing.

(2) Automated testing can automate tasks and free manpower to do more important work.

(3) Automated testing only needs to deploy corresponding scenarios, such as highly complex usage scenarios, massive data interaction, dynamic response requests, etc., and the test can be carried out automatically in an unattended state, and the test results can be analyzed and fed back; manual Testing It is difficult to implement complex tests.

(4) Automated testing can simulate complex test scenarios to complete tests that cannot be done manually, such as load testing and stress testing.

(5) Regression testing is required after software version update iterations. Automated testing helps to create a continuous integration environment, and use the newly built testing environment to quickly perform automated testing

It can be seen that there are many advantages of automated testing, so in recent years, companies have been frantically recruiting automated testers. The continuous influx of high-paying automated testing gradually replaces low-paying manual testing. The direct consequence is that the average salary of testing has risen all the way in recent years.

picture


△ The screenshot comes from the collection of staff and friends, showing that the salary of the test has been rising all the way in the past 6 years

The specific implementation process of automated testing is shown in the following figure:

picture


Automated testing implementation flow chart

As can be seen from the above figure, to implement automated testing, it is necessary to build a test environment, that is, to build a test framework.

This is the fundamental reason why we have to learn "Building Interface Automation Test Framework" and "Building Ui Automation Test Framework".

ps: If you don’t want to build from scratch, but want to use the current mainstream automated testing framework, you can click this article hard:

"What kinds of automated testing tools are there for Android mobile phones? 128 Agreed 16 Comments & Answers
https://www.zhihu.com/question/19716849/answer/2930155323

2. Introduction How to build an API interface test framework

In the current application of practical testing skills in enterprises, functional testing and interface testing are the most widely used. However, compared with functional testing, the interface testing gap is very large. And interface testing has a very high status in the testing field, and it is the dividing line between junior and intermediate software testing engineers.

So let's build the interface test framework first, and the building steps are listed as follows:

1) Select the development language
2) Select Pytest as the test framework
3) Set up the test report
4) Select the code warehouse
5) Deploy the continuous integration solution
Attached: Two sets of detailed learning video recommendations

After the steps are explained, we begin to explain in detail how to operate each step (try to let you build it according to the steps).

1. Choose a language

We choose Python as the language. Because it is easier to get started than Java.

Python is an easy-to-learn, easy-to-understand computer programming language. There are not only a lot of learning books, but also a lot of learning videos. Python has already become the No1 of tiobe language.

picture

If you have not learned the Python language, the recommended dark horse learning materials are as follows:

"Take you to play python2020 version in 10 days"
link of this video station b: https://www.bilibili.com/video/BV1jZ4y1s7LC

2. Select PyTest as the test framework

PyTest is a very mature full-featured Python testing framework. The official documentation details its features

· Detailed display of failed assertion statements (no need to remember self.assert* names)
· Automatic discovery of test modules and functions
· Very convenient for managing small or parameterized test projects
· Can run unit tests and test suites out of the box
· Rich plugin architecture with over 800+ external plugins and a thriving community

picture


The pytest framework uses 5 steps​​​​​​​​

#PyTest目录结构apiTestFramework # 项目名称 ├── api # 定义封装被测系统的接口 ├── script # 定义测试用例脚本 ├── data # 存放测试数据文件 ├── report # 存放生成的测试报告 ├── common # 存放通用工具类 ├── config.py # 定义项目的配置信息 └── pytest.ini # pytest配置文件

3. Test report

After the test case is executed, a report can be generated from the execution result in HTML (web page). We choose pytest-html. It is a plugin for the PyTest framework to generate HTML test reports. Easy to use.

The first step of installation: pip install pytest-html

The second step is to modify the configuration: addopts = -s --html=report/report.html

Easy to do.

4. Code repository

Code management is definitely the first choice for git. Git distributed version control system, realize version control and multi-person collaboration.

picture

​​​​​​​
# 常见的代码托管平台:Github     国外的基于git实现在线代码托管的仓库(企业版收费)     官网:https://github.com/ Gitee     码云,是开源中国免费提供(企业版收费)    官网:https://gitee.com/ Gitlab     类似Github,一般用于企业内部搭建git私服

5. Continuous integration solution

picture

Jenkins is an open source, cross-platform continuous integration tool developed based on Java. He can continuously and automatically build/test software projects to monitor and execute tasks at regular intervals.

Let's briefly explain the core construction steps of jenkins.

1) Build the Jenkins environment

picture

2) Set up source code management after creating tasks

picture

3) Enter the build name

picture

4) Set a timed build

picture

5) Set test report path

picture

6) Send mail after setting build

picture

7) Build and view the result

picture

PS: No matter how detailed the text is, it is not as vivid as the video. Next, I recommend two detailed videos related to the interface testing framework:

1) "Python Realizes Interface Automation Test Video"
link of this video site b: https://www.bilibili.com/video/BV1uz411q7Pg

2) "Python Realizes Toutiao Project Interface Automation Test Actual Combat"
This video link of site b: https:/ /www.bilibili.com/video/BV1va4y1i76B

3. Teach by hand: how to build a UI automation testing framework

There are many UI automation testing frameworks. Let's take the pytest+selenium+allure+PO model as an example to give you a brief explanation. The construction steps are as follows:

1) Tool environment
2) Dependent packages
3) Project directory
4) Script writing steps

1. Tool environment

a)  Python解释器b)  Pycharm编码工具c)  Web端:d)  浏览器e)  浏览器驱动程序

2. Dependent packages

a)  Seleniumb)  pytestc)  pytest-html

3. Project directory

a)  base        基类python packageb)  page        PO封装python packagec)  case       测试用例python packaged)  data         数据文件Directorye)  report      测试报告Directoryf)  log           日志文件Directoryg)  screenshot      截图文件Directoryh)  config.py       项目配置信息文件i)  utils.py        工具类文件

4. Script writing steps

a) Initialization code

picture

b) A test case scripting process

picture

c) Introduce data-driven

picture

d) import log

picture

e) Generate test report

picture

PS:  If there is no foundation of basic knowledge, no matter how detailed the text is, people may not know how to start. Next, we recommend multiple UI automation testing framework videos, and build them according to the following videos.

-------------- Web class automation framework related videos ---------------

1) "Introduction to web automation in practice" 
link of this video station b: https ://www.bilibili.com/video/BV1ED4y197Nd

2) "8-Day Web Automation Introductory Tutorial" 
link to this video station b: https://www.bilibili.com/video/BV1eZ4y1s7BY

--------- -----App automation framework-related videos ---------------

1) "0-Basic Introduction to Mobile Automation Appium Framework" 
Link to station b of this video: https://www.bilibili .com/video/BV11p4y197HQ

2) "Appium conducts IOS real machine automation test"
link of this video station b: https://www.bilibili.com/video/BV1tT4y137bD

When introducing the "API interface testing framework" and "UI automation testing framework", we have repeatedly mentioned the Pytest testing framework. Is there a learning video for this framework? Of course there is, see the screenshot below:

picture

Pytest framework learning video is shared as follows:
"6-day UI Automation_Pytest Framework Learning-2021 Edition" 
link of this video station b: https://www.bilibili.com/video/BV18Q4y1y7v3

Fourth, automated testing framework e-book recommendation

I believe this book should be of great help to you--"Web Interface Development and Automated Testing"

picture

There is an e-book link to share below

Attachment: The free download address of this e-book:
http://bbs.itheima.com/thread-514629-1-1.html

Recommend another book about UI automation testing--"Python Realizes Web UI Automation Testing Practical Combat"

This book mainly introduces how to use Selenium, unittest, Pytest, GitLab, Jenkins and other tools to implement Web UI automation testing based on Python to help improve the testing level.

picture

I can't find the electronic version of this book. If you find it, you are welcome to share it. You can private message me

Guess you like

Origin blog.csdn.net/JACK_SUJAVA/article/details/131729018