python 接口自动化测试框架-unittest中assert的使用

一、assert的使用

import unittest

from base.runmain import RunMain

class testcase(unittest.TestCase):

    def setUp(self):
        print("case执行前")

    def test_01(self):
        url = 'http://www.oktest.org.cn/siteApp/command/ecGzSubSearch?fid=t_xmosta&siteId=2808&search=1'
        data = {
            'searchKey': "测试",
            'x': '30',
            'y': '8'
        }
        headers = {
            'Content-Type': 'application/json'
        }
        run = RunMain()
        res = run.run_main(url=url,data=data,headers = headers,method='post')
        self.assertEqual(None,res,"测试失败")

    def test_02(self):

        url = 'http://www.oktest.org.cn'
        run = RunMain()
        res = run.run_main(url=url,data=None,headers=None,method='get')
        self.assertEqual(None,res,"测试失败")

    def tearDown(self):
        print("case执行后")

if __name__ == '__main__':
    unittest.main()

结果
python 接口自动化测试框架-unittest中assert的使用_第1张图片

你可能感兴趣的:(接口自动化测试框架,python)