The introduction

As a developer, I sometimes need to assist the Marketing Department in development. For example, in marketing promotion, I often give coupons to users to improve the repeat purchase rate. This article will show you how to build this business logic using the automated tests [UI mode] of the interface management tool eoLinker.

keywords

Marketing, scheduled tasks, data association

Next, we take giving coupons to users as an example to set up the process. Once you’ve set up the process, you’ll find that you don’t need to write complex code anymore, you can do it in a few simple steps.

directory

1. Process design 2. Process debugging 3. Scheduled task 4

1. Process design

Let’s first identify the interface needed to complete the business logic:

Interface 1 Login: A basic login interface for marketing personnel to log in to their accounts. Interface 2 Get user list: Determine the user list before issuing coupons. Interface 3 Get coupon list: Get various types of coupons. Interface 4 gives a coupon to the user: the result of interface 2 and interface 3 is used as the request parameter. Interface 5 Log out: Log out after completing the service process.

According to the above process design, I created 5 interfaces as shown in the following figure and adjusted the correct test sequence.

The return parameter of interface 1, statusCode, I set 4 status codes, exactly correspond to 4 possible cases, if there are more possibilities, you can continue to add.

If an interface has been established in the API document, you can batch add the existing interface in automatic common UI mode.

After editing the interface and setting up the data association, just go back to the automated test page and click “Test All” to complete the test. How to correlate data is described below. As you can see in the figure below, we had a successful test with the correct setup.

2. Process debugging

In a process test, the return parameter of the previous interface may be the request parameter of the next interface. That’s where you need to use the associated data. For example, to send a coupon to the user, you need to pass the coupon couponID returned by the previous interface. There are two steps for data association:

  • Step 1: Get the return value of the coupon list. We have 3 coupons of different denominations: 100 minus 10, 1000 minus 100 and 10000 minus 1000, corresponding to different Couponids.

  • Step 2: Fill in the request parameters of interface 4. The request parameters of interface 4 are the return parameters of interface 2 and interface 3.

Click the “Associate” button at the back, and the following popup box will appear. Select the data to associate, for example, couponID is selected in the following figure.

Generate binding values. Both userID and couponID in the figure generate binding values. < Response [39677].userList. UserID > The parameter value is in the format of the association parameter specified by eoLinker. The return value wrapped with a single book name is response[association ID of the interface (which can be viewed in the singleton list)]. Parameters. If the child argument of the return value is an array, the element ordinal is required, with the first element being 0, and so on. Such as couponList [0]. Correlation parameters can be used in the request header, request body (form-data, RAW), and REST parameters. Test reports are also very important in debugging. Using normal UI automation mode, a detailed test report is generated after the test is complete, and you can see the complete test report by viewing the details. If the test fails, the test report can be corrected in time.

3. Scheduled tasks

In this article’s business process, we can automate the entire process by scheduling test tasks. Start by adding the task to the scheduled Test Task, the second-level menu for automated tests. Before adding tasks, you need to add groups. For example, the group of “giving users coupons” is created here.

You need to fill in the name: “Give coupons to users”, set the time to “permanently valid”, set the period to “one week”, set the date to “10:00 am and 6:00 PM from Monday to Friday”, and send coupons according to such rules. In the use case list, select the use case you set up earlier: Coupons

Confirm the test environment, fill in my email address, and then select the notification type. After setting this up, we can get all the information about the interface test and make sure the interface works just by checking the email.

As shown above, each test history can be conveniently downloaded from the test Task list.

4. Use Tips

Request parameter handling

Some parameters, such as passwords, need to be encrypted before sending. In eoLinker, the parameter userPassword can be encrypted with code injection. For example, for interface 1, I used the built-in encryption method of eoLinker to encrypt the request parameter userPassword with MD5 and SHA1.

In the navigation bar on the right side of the code injection function, eoLinker currently has three built-in encryption methods including MD5, which can be called directly by clicking on it. If you want to use other encryption methods, you can use Javascript and Jquery code to encrypt with some simple syntax. You can also do something else to the request parameters before sending.

Return parameter match

In addition to processing the request parameters, the returned parameters also need to be verified. In this business, we only select specific users to send corresponding coupons, which needs to be verified to match the returned parameters.

For interface 2, I need to judge the return value before deciding whether to continue the automated test process. If eoLinker verification fails, the test stops by default. If you don’t want to stop here, check the box below “Execute the next use case even if the check bit of this use case fails”. This will continue testing even if it fails.

Let’s talk about the verification rules

Check rule: statusCode is the string 000000. The couponID in the list is 1, and the couponName is 100 minus 10

Verification rules entered by eoLinker:

5, summary

Finally, complete the task and log out, and a complete business process is complete. Through the UI mode of automated testing for business process testing, it does not need to write code, and can timely correct errors through the test report, which greatly improves the work efficiency compared with the traditional testing method.

EoLinker, efficient, professional, standard, make interface management more simple!

For more updates, please visit eoLinker’s wechat official account. This article is transferred from eoLinker’s official account.

Try it now: www.eolinker.com