zoukankan      html  css  js  c++  java
  • pytest.mark对测试接口进行打标签

    1.首先需要pycharm需要安装ini插件

    2.在项目的最外层创建  pytest.ini 文件(名字必须一样),标签距离左边一个tab键

    [pytest]
    markers =
        test_addCustomer: 创建直客商户 #标注可以不写
        test_login: 登录接口

    3.给接口进行打标签

    @pytest.mark.test_addCustomer
        @pytest.mark.test_addCustomer
        @allure.story('创建直客商户')
        @pytest.mark.parametrize('data',get_excelData('loginCases.xls','创建直客',2,2,5,6))
        @pytest.mark.parametrize('test_uploadimg',filesNames,indirect=True)
        @pytest.mark.parametrize('test_send_code',datas,indirect=True)
        def test_addCustomer(self,data,test_JYBCBOxmjd,test_jyb_CBO_USER_PP_POSITION,test_jybBusinessType,test_send_code,test_uploadimg):
            '''
            :param data: excel读出的数据
            :param test_JYBCBOxmjd:随机获取客户来源
            :param test_jyb_CBO_USER_PP_POSITION:随机获取职位信息
            :param test_jybBusinessType:获取企业类型--写死企业
            :param test_send_code:发送短信验证码的手机号
            :param test_uploadimg:图片上传服务器文件路径
            :return:客户ID
            '''
            res = Customer(self.cookies).addCustomer(data[0],test_JYBCBOxmjd,test_jyb_CBO_USER_PP_POSITION,test_jybBusinessType,test_send_code,test_uploadimg)
            assert res['success'] == data[1]['success']
            print(f"直客创建成功------客户ID:{res['resultInfo']}")
            return res['resultInfo']
    pytest.main(['test_addCustomer.py','-s','-k','test_Customer','--alluredir','../../report/apiReport/tep'])

    -k:模糊匹配

    标签名:test_Customer

    注意:命明最好不要用add类似的前缀,有可能会造成标签没有作用。
  • 相关阅读:
    HDU 1527 取石子游戏 (威佐夫博奕)
    HDU 1159 Common Subsequence (LCS)
    HDU 1160 FatMouse's Speed (LIS)
    HDU 2577 How to Type (DP)
    csu 1395: Timebomb (模拟)
    csu 1556: Jerry's trouble(大数取模)
    csu 1553: Good subsequence (最长连续子序列)
    csu 1548: Design road (三分)
    csu 1547: Rectangle (01背包)
    csu 1541: There is No Alternative(Kruskal 最小生成树)
  • 原文地址:https://www.cnblogs.com/zhuxibo/p/13921581.html
Copyright © 2011-2022 走看看