gpt4 book ai didi

selenium - Gherkin 机器人框架中的场景概述

转载 作者:行者123 更新时间:2023-11-28 21:08:45 25 4
gpt4 key购买 nike

我想以 Robot Framework 中可能最“优雅”的方式将多个参数传递给我的测试用例。许多框架中使用的场景大纲允许用表中的值替换变量/关键字。表中的每一行都被认为是一个场景。

Robot Framework 中是否有任何等效的场景大纲?

例如我们有这样的测试用例:

Given users email is ${email}
And users password is ${password}
When user is on login page
Then user can sign in

我们想将多个电子邮件和密码作为一个数组传递给这个测试用例,并运行与这个数组中的行一样多的次数。我可以在不将测试用例转换为关键字以使用模板的情况下这样做吗?

最佳答案

您不能将 BDD 式测试与数据驱动测试混合使用。最接近的做法是以 BDD 风格编写关键字,然后在实际测试用例中使用该关键字。

例如,您可以这样做:

*** Keywords ***
users email is
[Arguments] ${email}
set test variable ${current email} ${email}

users password is
[Arguments] ${password}
set test variable ${current password} ${password}

User is on login page
log pretend we are on the login page

User can sign in
should contain ${current password} !
... password for ${current email} doesn't contain '!' (${current password})
... values=False

User login template
[Arguments] ${email} ${password}

Given users email is ${email}
And users password is ${password}
When user is on login page
Then user can sign in

*** Test Cases ***
Scenario: user can sign in with valid credentials
[Template] User login template

# username # password
larry@example.com heymo!
moe@example.com wiseguy!
curly@example.com nyuknyuk!

关于selenium - Gherkin 机器人框架中的场景概述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44801940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com