API interface use case generator

I. Introduction

With the popularization of automated testing technology, there are already many companies or projects that more or less conduct automated testing.

At present, the automated testing of this department is mainly based on interface automation. The interface use cases are maintained by Excel, and the rules are written according to the established interface use cases. For functional testers, as long as the interface use cases are well maintained, the interface automation test can be successfully executed.

For each new interface, the interface test must be carried out first. The tool used is Postman. After the interface test and function test pass, the interface automation use case writing work will be carried out later. So what other optimizations can be made in this process to quickly improve work efficiency?

The idea is that interface use cases can basically be written without writing, but directly convert existing Postman scripts into interface use cases. For this reason, the author has developed a tool for generating interface use cases - API interface use case generator. Currently, the tool is already in Landed in the project and promoted its use.

2. Introduction

The API interface use case generator is written in Python and uses Tkinter for GUI encapsulation.

Features:

1. Support GET and POST request methods

2. Support HTTP and HTTPS request protocols

3. Support continuous generation of interface use cases

4. Support to create different Sheet pages

5. According to the operating system, it is divided into Windows (.exe) and Mac (.app) versions, which can be used without installation

3. Get started quickly

Example: Operating in a Mac environment.

Open the API interface use case generator, which is mainly divided into three areas:

1. Input area: use case name (cannot be repeated), Sheet name (default Sheet1), request protocol (HTTP, HTTPS), request data (the code in Postman is the interface content of HTTP)

2. Output area: return data (after running, the return value requested by the interface in real time)

3. Operation area: run (run the interface and generate interface use cases), reset (clear the use case name, request data and return data), close (close the generator), help (get help information)

If you want to learn interface automation testing, here I recommend a set of videos for you. This video can be said to be the number one interface automation testing tutorial on the entire network at station B. At the same time, the number of online users has reached 1,000, and there are notes to collect and use. Technical exchanges of various masters: 798478386      

[Updated] The most detailed collection of practical tutorials for automated testing of Python interfaces taught by station B (the latest version of actual combat)_哔哩哔哩_bilibili [Updated] The most detailed collection of practical tutorials for automated testing of Python interfaces taught by station B (actual combat) The latest version) has a total of 200 videos, including: 1. [Interface Automation] The current market situation of software testing and the ability standards of testers. , 2. [Interface Automation] Fully skilled in the Requests library and the underlying method call logic, 3. [Interface Automation] interface automation combat and the application of regular expressions and JsonPath extractors, etc. For more exciting videos, please pay attention to the UP account. https://www.bilibili.com/video/BV17p4y1B77x/?spm_id_from=333.337

Example 1: GET request

As shown in the figure below, open Postman, request the sample interface, and the interface request is successful.

Open the code area on the right side of Postman, select HTTP, and copy this code.

Paste the copied code into the request data of the generator, enter the use case name and Sheet name, and click Run.

 

When the operation is completed, it prompts that the operation is successful.

 

The request result is displayed in the return data of the generator.

 

At this point, the interface use case is automatically created on the desktop.

Open Excel, you can see that the use case has been successfully generated according to the established rules. 

 

 Example 2: GET request (parameter + request header)

As shown in the figure below, in the opened Postman, request the sample interface, and the interface request is successful.

Also open the code area on the right side of Postman, select HTTP, and copy this code.

 

Paste the copied code into the request data of the generator, enter the use case name and Sheet name, and click Run.

 

The operation is successful, and the request result is displayed in the returned data of the generator.

 

Since the Excel file already exists, there is no need to create it again. Open Excel, and you can see that the use case has been successfully generated according to the established rules.

 

Example 3: POST request (json format)

As shown in the figure below, in the opened Postman, request the sample interface, and the interface request is successful.

Also open the code area on the right side of Postman, select HTTP, and copy this code.

 

Paste the copied code into the request data of the generator, enter the use case name and Sheet name, and click Run.

 

The operation is successful, and the request result is displayed in the returned data of the generator.

 

Click Run again and want to generate a use case. At this time, it prompts that the name of the use case cannot be repeated, and it needs to be renamed before running.

 

Change the use case name to be unique, and modify the value of the request parameter, click Run, and the request is successful.

 

Open the Excel use case at this time, and you can find the use cases of the two POST request types generated by the execution just now.

 

In addition to the normal operation function, some logical judgment prompt information has been added.

For example, when the use case name and request data are both empty, click Run directly, and the prompt information will be given.

When an error is reported during operation, the error message is given and the error details are listed.

 

 Click the Help button to give the solution information.

 

 

 

Guess you like

Origin blog.csdn.net/caixiangting/article/details/132150038