Interface testing react+unittest+flask interface automation testing platform

Table of contents

1 Introduction

2 frames

2-1 Framework Introduction

2-2 Framework introduction

2-3 Frame structure

3 platforms

3-1 Platform component diagram

1 Create a new use case

2 Generate test tasks

3 Execute and view the test report

3-2 Use Case Management

3-2-1 Use case design

3-3 Task Management

3-3-1 Create a task

3-3-2 Executing tasks

3-3-3 Test report

3-3-4 Email Notification


1 Introduction

It is a good choice to build an interface automation testing platform based on React, Unittest and Flask. React is a popular JavaScript library for building user interfaces, and Unittest is a unit testing framework for Python for writing and executing test cases. Flask is a lightweight Python web framework that can be used to build interfaces.

There are many tools for interface automation testing, such as soapUI, postman, jmeter, etc., but the scalability of these general tools and the fit with the project are not very suitable.
The framework alone is not enough to simplify the interface automation. Automated testing requires a lot of coding and maintenance work. In order to improve these problems and liberate repetitive labor, it is made into a platform that can be used by people who do not understand technology. , and also make the interface use cases simpler and clearer, and easier to maintain.

Simple demonstration of the usage process.

2 frames

2-1 Framework Introduction

The front-end is implemented in reactjs language, and the background is provided by flask with a restful interface. Based on the python unittest test framework, one-click generation of test scripts and visual maintenance of test data.

2-2 Framework introduction

1-Based on the Python+unittest testing framework
2-The urlib library is encapsulated twice, and the cookies and data dependent on the business process are saved, so that the business process and different request scenarios can be tested coherently.
3-Support multi-project, expansion of different environment data parameters.
4-Support the code of the return value and the verification of the specified field to improve the accuracy of the test.
5- Scheduled tasks and real-time task execution to meet the requirements of automated business testing of stable interfaces and debugging and testing of temporary interfaces.
6-Online report display and Email automatic report sending

2-3 Frame structure

Structure diagram:

It is divided into two sets of codes: front and back

3 platforms

3-1 Platform component diagram

1 Create a new use case

2 Generate test tasks

3 Execute and view the test report

3-2 Use Case Management

Write automated tests online so that everyone can participate in the test
Automated use case editing visualization makes the automation process simpler and clearer
For parameter values ​​that need to be acquired in a continuous process, provide json-type data analysis to obtain specified values.

3-2-1 Use case design

Platform use case execution flow chart

3-3 Task Management

3-3-1 Create a task

According to the test case, generate the test task of specifying the domain name or test machine ip.

3-3-2 Executing tasks

The scheduled task is to automatically execute the specified test task set at the specified time point every day.
After each execution (including manual execution and scheduled tasks), a test report will be generated and sent to the designated person.

3-3-3 Test report

According to the test time and the given file name, an html visual report corresponding to the time can be generated. The report content includes the test time consumption, the total number of test execution cases, the number of successful, failed, and error cases; and the execution status of a single use case (ID, Use case name, server return value, operation result, etc.)

3-3-4 Email Notification

The sender and receiver are temporarily written in the code. Check the requirements and see if it needs to be configured as a front-end. The email will directly display the report result, and you can also view the detailed content of the attachment.

  As someone who has been here, I also hope that everyone will avoid some detours

Here I will share with you some necessities of the way forward in automated testing, hoping to help you.

(WEB automated testing, app automated testing, interface automated testing, continuous integration, automated test development, big factory interview questions, resume templates, etc.)

I believe it can make you better progress!

Click on the small card below

Guess you like

Origin blog.csdn.net/Free355/article/details/131700404