搜索
您的当前位置:首页正文

robotframework-自动化测试-实例9(行为驱动)

来源:哗拓教育

前情介绍:
行为驱动是一种在关键词驱动之上更加抽象更加高级的自动化测试手段;通常结构是“Given-When-and-Then”,即在一个什么样的前置条件下,当用户触发了什么操作,产生了一个什么样的结果,结果该是怎么样。

行为驱动风格的测试用例(given-when-then),官方称谓是gherkins风格的。。。

***Test Cases***
 User can change password
    Given A user has a valid account
    when she changes her password
    Then she can log in with the new password
    And she cannot use the old password anymore

测试需求:

测试设计:
因为BDD(行为驱动测试)这个方式我个人理解是更多的是一种沟通方式。

此次的例子只是一个简单的秀肌肉行为,也就是你知道写法就可以了,其实个人觉得和关键字驱动的差别就在于刚开始的测试用例的写法上面。

测试实现:

  1. 新建测试用例
  2. 所有的实现语句都以关键字的形式存在
    上代码:
*** settings ***
Library           Selenium2Library

*** Test Cases ***
Scenario: No template operation selected
    Given I have logged in and I have selected to perform template configuration
    When I do not select a template operation
    And I press the next button
    Then I should not see a template operation selected error message

*** Keywords ***
I have logged in and I have selected to perform template configuration
    Log    Given I have logged in and I have selected to perform template configuration
    open browser        chrome

I do not select a template operation
    Log    No template operation selected

page does not contain a no template operation selected error message
    Page Should Not Contain    'ddTemplateOperation' is required.

I press the next button
    Log    I press the next button

I should not see a template operation selected error message
    Page Should Contain    'ddTemplateOperation' is required.
   Close Browser
Top