美文网首页程序员简友广场散文
HttpRunner的校验检查点

HttpRunner的校验检查点

作者: xianling_he | 来源:发表于2020-05-15 20:51 被阅读0次
    • 有些时候会遇到多个步骤执行,但是检查验证在后面的步骤中
    • 比如登陆以后创建表单,检查表单是否创建成功
    • 比如登陆以后确定账号登陆是否成功

    将创建成功的文章修改标题

    • 找到修改标题的请求
    -   name: /v3/api/colla/message
        request:
            headers:
                Content-Type: application/json;charset=UTF-8
                Jwt-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIzODc4MTMxIiwiZXhwIjoxNTkxODgyNTc3LCJpYXQiOjE1ODkyOTA1Nzd9.Ee_Qpu2XpW_WKIJQwJU_eOJNM6AEI8J8tk6ZLMRkhug2ndPM-TfVOzEMdxGz9Fw9HrqY-2YLz9PJhenlTLeHlA
                Member-Id: '${memberId}'
                Request-Id: MESSAGE:${userId}:${memberId}:9
                Sec-Fetch-Dest: empty
                Sec-Fetch-Mode: cors
                Sec-Fetch-Site: same-site
    
    • 将固定的title值改成变量值${new_title}
                data:
                    message:
                        content:
                        -   name: nameChanged
                            original: test123
                            title: ${new_title}
                        documentId: ${documentId}
                        type: CHANGE
                        version: 3
                        viewType: OUTLINE
    
    • 将变量定义在var里面,这里先尝试使用固定值
        variables: 
            documentId: 28nRA1U6DVz
            memberId: "1576021112575"
            userId: "3878131"
            new_title: "New_title_Sam"
    

    因为修改某个文章的标题,首先需要登录系统

    • 如果你直接执行change_title的脚本,会遇到提示说明login是失败,没有登录系统
     hrun testcases/change_title.yml --log-level debug
    

    -结果显示如下:

    AssertionError:
    validate: content.code equals 0(int)    ==> fail
    2(int) equals 0(int)
    
    validate: content.msg equals None(NoneType)     ==> fail
    您尚未登录或已经超时,请重新登录。(str) equals None(NoneType)
    
    未登录系统.png

    将login部分的请求添加到change_title的步骤里面,这样就可以修改title并成功

    -   name: login the mubu
        testcase: testcases/login.yml
    
    添加login步骤.png

    重新执行login - change title

     hrun testcases/change_title.yml --log-level debug
    
    • 结果显示如下


      image.png
    报告.png mubu.png

    总结

    1.需要将变量放在variables里面,可以存放固定值,也可以是变量值
    2.替换的参数使用${title_name}的格式

    • 前面的variables里面是其他参数比如memberid ,userid, document id等值,这些参数的取值及传递如何实现

    相关文章

      网友评论

        本文标题:HttpRunner的校验检查点

        本文链接:https://www.haomeiwen.com/subject/bxxcohtx.html