Behavemimicscenariooutlineoutputwithexecute_steps
创始人
2024-11-28 01:30:20
0

在Behave框架中,可以使用execute_steps方法来模拟场景大纲输出。代码示例如下:

from behave import step, given, when, then, use_step_matcher
from behave.model import Table

use_step_matcher("parse")

@given("I have a list of numbers")
def step_impl(context):
    context.numbers = [1, 2, 3, 4, 5]

@when("I add {number:d} to each number in the list")
def step_impl(context, number):
    for i in range(len(context.numbers)):
        context.numbers[i] += number
    # Use execute_steps to mimic scenario outline output
    context.execute_steps(f"""
        Then the list should be:
            | numbers |
            | {" | ".join(str(n) for n in context.numbers)} |
    """)

@then("the list should be:")
def step_impl(context):
    expected = [list(map(int, row)) for row in context.table]
    assert context.numbers == expected[0]

在这个例子中,当执行'I add 2 to each number in the list”的步骤时,使用execute_steps方法来模拟输出场景大纲。执行该步骤后,将会执行与'the list should be:”步骤相同的表格验证步骤,以检查预期输出是否与实际输出匹配。

上一篇:Behave枚举

下一篇:Behaveoptional相关

相关内容

热门资讯

一分钟辅助!拱趴大菠萝挂,hh... 一分钟辅助!拱趴大菠萝挂,hhpoker开挂教程,教程书教程(讲解有挂)1、hhpoker开挂教程辅...
八分钟辅助!wepoker私人... 八分钟辅助!wepoker私人局透视插件,wepoker亲友圈有用吗,攻略教程(讲解有挂)1、让任何...
两分钟辅助!wpk模拟器是什么... 两分钟辅助!wpk模拟器是什么,aapoker怎么选牌,演示教程(有挂秘笈)1、wpk模拟器是什么辅...
九分钟辅助!hhpkoer辅助... 您好,hhpkoer辅助器这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很...
第4分钟辅助!wepoker智... 第4分钟辅助!wepoker智能辅助插件,we poker插件,攻略教程(有人有挂)在进入wepok...
2分钟辅助!hhpoker买挂... 2分钟辅助!hhpoker买挂,hhpoker脚本,方针教程(了解有挂)1、hhpoker买挂脚本辅...
七分钟辅助!哈糖大菠萝开挂,德... 七分钟辅助!哈糖大菠萝开挂,德州hhpoker脚本,秘籍教程(有挂细节)1、许多玩家不知道哈糖大菠萝...
第二分钟辅助!wpk真吗,we... 第二分钟辅助!wpk真吗,wejoker辅助软件价格,举措教程(有挂技巧)wejoker辅助软件价格...
9分钟辅助!wepoker透视... 9分钟辅助!wepoker透视最简单三个步骤,wepoker辅助器有哪些功能,指引教程(确实有挂)运...
第7分钟辅助!哈糖大菠萝有没有... 第7分钟辅助!哈糖大菠萝有没有挂,pokemmo辅助脚本,积累教程(有挂技巧)1、起透看视 哈糖大菠...