Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of knowledge points of interface testing

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "the summary of knowledge points of interface testing". In the daily operation, I believe that many people have doubts about the summary of knowledge points of interface testing. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "knowledge point summary of interface testing"! Next, please follow the editor to study!

Python coding for interface testing steps

We take the http interface sent by python as an example to test the http interface through requests module in python. The specific steps are as follows:

Step 1: build the interface

Install pip install requests

Build a mock interface in rap2 (you can register rap2 yourself and build your own rap2 interface) http://rap2api.taobao.org/app/mock/85630/getinfo

The response values of the defined interfaces are as follows:

Step 2: send interface

The core code is as follows:

Import requests req= "http://rap2api.taobao.org/app/mock/8563/getinfo" response=requests.get (req) print (response.text) output: {" code ": 0," message ":" ok "}

Step 3: verify the interface

Because the code generation rule defined in the build interface is 0-10, we need to verify it. Because the response data is in json format, we also need to use the json module to parse the response. The specific code is as follows:

Import json import requests req= "http://rap2api.taobao.org/app/mock/85630/getinfo" response=requests.get (req) print (response.text) # parses the response code as follows: code=json.loads (response.text) .get ('code') print (code) if code

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report