【问题标题】:How to validate each test case in Robot Framework如何验证 Robot Framework 中的每个测试用例
【发布时间】:2016-01-09 13:39:45
【问题描述】:

如何验证 Robot Framework 中的每个测试用例。就像我有 3 个字段名称、编号和加入日期和保存按钮一样,都是必填字段。

第一个案例-->我将输入号码和加入日期,然后单击保存按钮,然后将出现验证消息“请输入姓名”

第二种情况-->我将输入姓名和加入日期,然后单击保存按钮,然后将出现验证消息“请输入号码”

第三种情况-->我将输入姓名和号码并单击保存按钮,然后将出现验证消息“请输入加入日期”

第四种情况-->1000 已经添加,然后如果我输入姓名、编号、加入日期,点击保存按钮验证消息将出现“重复员工编号”

如果我使用测试模板,如何处理这种情况需要使用“测试模板”

*** Settings ***
Documentation     A test suite containing tests related to invalid login.
...
...                     These tests are data-driven by they nature. They use a single
...                   keyword, specified with Test Template setting, that is called
...                    with different arguments to cover different scenarios.
...
...                    This suite also demonstrates using setups and teardowns in
...                    different levels.
Test Template     Invalid Data
Resource           resource.txt

*** Test Cases ***                           Number                     Name                    Join Date       
Empty Employee Number               ${EMPTY}                  Foo                       01 Apr 2015         
Empty Employee Name                  1000                         ${EMPTY}               01 Apr 2015
Empty Join Date                            1000                          Foo                        ${EMPTY}

*** Keywords ***
Invalid Data
      [Arguments]    ${employeenumber}    ${name}    ${doj}
      Enter Employee Number        ${employeenumber}
      Enter Employee Name           ${name}
      Enter Join Date                     ${doj}
      Validation check for Invalid Data

Validation check for Invalid Data
       Page Should Contain        Please enter the Name
       Page Should Contain        Please enter the Number
       Page Should Contain        Please enter the Join Date  

如果我这样使用,那么第一个测试用例为通过,其余测试用例将失败,因为对于第二个测试用例,它将检查“页面应包含请输入名称”,但对于第二个测试用例,我们是已经添加了数字。如何在 Robot Framwork 中处理这些情况,任何人都可以帮助我。

【问题讨论】:

  • 您的文字难以阅读。请问可以正确格式化吗?

标签: robotframework


【解决方案1】:

为您要验证的内容添加另一个参数

*** Keywords ***
Invalid data
[Arguments]    ${employeenumber}    ${name}    ${doj}    ${expected}
...
Page should contain    ${expected}

*** Test Cases ***      Number    Name      Join Date     Expected       
Empty Employee Number   ${EMPTY}  Foo       01 Apr 2015   Please enter the name
Empty Employee Name     1000      ${EMPTY}  01 Apr 2015   Please enter the number
Empty Join Date         1000      Foo       ${EMPTY}      Please enter the Join Date

【讨论】:

    猜你喜欢
    • 2016-05-05
    • 2022-08-20
    • 2019-09-03
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 1970-01-01
    • 2017-09-21
    • 2016-01-13
    相关资源
    最近更新 更多