zoukankan      html  css  js  c++  java
  • httprunner3.x 测试用例-teststeps-RunTestCase

    通过RunTestCase对其他测试用例进行调用,并且还可以导出用例中所需要的变量,来满足后续用例的的运行。

    主要的两个特征:一个是在一个用例中引用另一个测试用例,另一个则是变量的导出与引用

     teststeps = [
            Step(
                RunTestCase("request with functions")
                .with_variables(
                    **{"foo1": "testcase_ref_bar1", "expect_foo1": "testcase_ref_bar1"}
                )
                .call(RequestWithFunctions)
                .export(*["foo3"])
            ),
            Step(
                RunRequest("post form data")
                .with_variables(**{"foo1": "bar1"})
                .post("/post")
                .with_headers(
                    **{
                        "User-Agent": "HttpRunner/${get_httprunner_version()}",
                        "Content-Type": "application/x-www-form-urlencoded",
                    }
                )
                .with_data("foo1=$foo1&foo2=$foo3")
                .validate()
                .assert_equal("status_code", 200)
                .assert_equal("body.form.foo1", "bar1")
                .assert_equal("body.form.foo2", "bar21")
            ),
    ]

    1. RunTestCase(name)

    这个参数还是一个名称,毕竟RunTestCase还是一个Step,这个名称同样会在日志和报告中显示。

    2. .with_variables

    这个变量跟RunRequest里的用法一样。

    3. .call

    这里就是指定要引用的testcase类名称了。

     

    4. .export

    可以指定要导出的变量,以供后续Step引用。
    可以看的.export()内部是一个列表[],这里可以用来导出多个变量

  • 相关阅读:
    【2021-08-09】问题还需一点一点去改正
    【2021-08-08】连岳摘抄
    【2021-08-07】请教帖
    21春助教总结
    实践总结+技术博客评分
    来吧 ,来吧 自己搭建一个erp 系统
    博客索引
    「CCNU21暑期第六次周赛」
    「CCNU21暑期第五次周赛」
    「图论」连通性问题
  • 原文地址:https://www.cnblogs.com/may18/p/13345102.html
Copyright © 2011-2022 走看看