测试人社区

接口测试训练营0610

准备环境

  • python3
  • pycharm

requests

https://requests.readthedocs.io/en/master/

httpbin练习

http://httpbin.ceshiren.com/ https://httpbin.ceshiren.com/

企业微信
https://work.weixin.qq.com/api/doc/90000/90135/90664

接口测试持续集成

http://docker.testing-studio.com:8080/job/霍格沃兹测试学院-接口测试演练/

环境准备


安装requests

使用pytest

第一个测试用例

接口测试框架Requests

企业微信真实案例实战

https://work.weixin.qq.com/api/doc/90000/90135/92117

  • 获取所有的标签
  • 添加标签
  • 删除标签
import requests

from wework import Wework


class TestWework:
    def setup_class(self):
        self.wework = Wework()
        self.token = self.wework.token_get()

        #清理所有的测试用的tag
        for tag_name in ["0610", '0611']:
            tag_id = self.wework.tag_find(tag_name)
            if tag_id is not None:
                r = self.wework.tag_delete(tag_id)
                print(r.text)
                assert r.json()['errcode'] == 0


    def setup(self):
        pass


    def test_tags_list(self):
        r = self.wework.tag_list()
        print(r.text)
        assert r.status_code == 200
        assert r.json()['errcode'] == 0

    def test_tag_add(self):
        r = self.wework.tag_add("0610", '0610')
        print(r.text)
        assert r.json()['errcode'] == 0

    def test_tag_delete(self):
        # 解除顺序依赖
        self.wework.tag_add('0610', '0611')
        tag_id = self.wework.tag_find("0611")
        r = self.wework.tag_delete(tag_id)
        print(r.text)
        assert r.json()['errcode'] == 0

接口测试的持续集成