Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 小黄瓜机器人框架中的场景概述_Selenium_Testing_Automated Tests_Robotframework_Gherkin - Fatal编程技术网

Selenium 小黄瓜机器人框架中的场景概述

Selenium 小黄瓜机器人框架中的场景概述,selenium,testing,automated-tests,robotframework,gherkin,Selenium,Testing,Automated Tests,Robotframework,Gherkin,我想在Robot框架中以最“优雅”的方式将多个参数传递给我的测试用例。许多框架中使用的场景大纲允许用表中的值替换变量/关键字。表中的每一行都被视为一个场景 Robot框架中的场景大纲是否有任何等价物 例如,我们有这样的测试用例: Given users email is ${email} And users password is ${password} When user is on login page Then user can sign in *** Keywords *** use

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

Robot框架中的场景大纲是否有任何等价物

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

Given users email is ${email}
And users password is ${password}
When user is on login page
Then user can sign in 
*** 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!

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

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

例如,您可以这样做:

Given users email is ${email}
And users password is ${password}
When user is on login page
Then user can sign in 
*** 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!

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

例如,您可以这样做:

Given users email is ${email}
And users password is ${password}
When user is on login page
Then user can sign in 
*** 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!
在Robot框架中使用类似小黄瓜的数据表(这是一个优雅的解决方法)可以看到这一点

以下是示例代码:

***设置***
强制标签仅限ISONE
资源BDD.robot
***测试用例***\Closed Period Open Period在旧管理器上运行导入停止新管理器启动
1示例1.11.2009-30.11.2009 1.12.2009-31.12.2009 11.11.2009 30.11.2009 1.12.2009
2示例1.11.2009-30.11.2009 1.12.2009-31.12.2009 1.11.2009 31.10.2009 1.11.2009
3示例1.11.2009-30.11.2009 1.12.2009-31.12.2009 1.12.2009 30.11.2009 1.12.2009
***关键词***
例子
[参数]${periodClosed}${periodOpenAndModified}${importDay}${oldManagerValidUntil}${newManagerValidFrom}
给定商业奖金的初始化标准
a分行B,分行经理M_OLD和员工E1
以及对已关闭的${periodClosed}期间的E1求值
以及对打开和修改的${periodOpenAndModified}期间的E1求值
当M_NEW成为B分行的新经理时
并在${importDay}上调用导入服务
那么分支B的新分支管理器是M_new valid from${newManagerValidFrom}
分行经理M_OLD管理员工E直到${oldManagerValidUntil}
分行经理M_NEW从${newManagerValidFrom}管理员工E
E1的评估仍然具有相同的内容
给定商业奖金的初始化标准
但是M_NEW成为了B分公司的新经理
但是在${importDay}上调用导入服务
M_OLD成为C分支的新经理
在Robot框架中使用类似于小黄瓜的数据表(这是一个优雅的解决方法)

以下是示例代码:

***设置***
强制标签仅限ISONE
资源BDD.robot
***测试用例***\Closed Period Open Period在旧管理器上运行导入停止新管理器启动
1示例1.11.2009-30.11.2009 1.12.2009-31.12.2009 11.11.2009 30.11.2009 1.12.2009
2示例1.11.2009-30.11.2009 1.12.2009-31.12.2009 1.11.2009 31.10.2009 1.11.2009
3示例1.11.2009-30.11.2009 1.12.2009-31.12.2009 1.12.2009 30.11.2009 1.12.2009
***关键词***
例子
[参数]${periodClosed}${periodOpenAndModified}${importDay}${oldManagerValidUntil}${newManagerValidFrom}
给定商业奖金的初始化标准
a分行B,分行经理M_OLD和员工E1
以及对已关闭的${periodClosed}期间的E1求值
以及对打开和修改的${periodOpenAndModified}期间的E1求值
当M_NEW成为B分行的新经理时
并在${importDay}上调用导入服务
那么分支B的新分支管理器是M_new valid from${newManagerValidFrom}
分行经理M_OLD管理员工E直到${oldManagerValidUntil}
分行经理M_NEW从${newManagerValidFrom}管理员工E
E1的评估仍然具有相同的内容
给定商业奖金的初始化标准
但是M_NEW成为了B分公司的新经理
但是在${importDay}上调用导入服务
M_OLD成为C分公司的新经理
字体:
https://gist.github.com/Tset-Noitamotua/8f06bd490918a56b0485630016aef60b


字体:
https://gist.github.com/Tset-Noitamotua/8f06bd490918a56b0485630016aef60b

测试用例不接受参数。你能更清楚一点你所说的“将参数传递给我的测试用例”是什么意思吗?你是在问如何使用吗?我加了一个例子来说明我的意思,我希望现在一切都清楚了。:)测试用例不接受参数。你能更清楚一点你所说的“将参数传递给我的测试用例”是什么意思吗?你是在问如何使用吗?我加了一个例子来说明我的意思,我希望现在一切都清楚了。:)好的,我知道这是在机器人框架中实现的方法。但请看这个例子:它不是将数据驱动测试与BDD混合在一起吗?对我来说,这是一个相当合理的解决方案,而机器人framemork中的这一点似乎很不清楚。但我是这门学科的初学者,我可能弄错了@Ewa:这个链接指向不同的测试框架。黄瓜和机器人是两种完全不同的东西。在每个测试框架中都有许多您无法在其他测试框架中完成的事情。Robot框架从来都不是为支持黄瓜语言gherkin而设计的。是的,我知道这些是不同的框架。我的问题是