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

2017-07-19  本文已影响540人  CC先生之简书

前情介绍:
行为驱动是一种在关键词驱动之上更加抽象更加高级的自动化测试手段;通常结构是“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

练习环境配置
实例1(UI自动化-百度搜索)
实例2(有效登录)
实例3(无效登录)
实例4 (Appium)
实例5 (连接mysql数据库)
实例6 (GET/POST请求)
实例7(接口API测试)
实例8 (数据驱动)
Appium Error总结
robotframework Error总结

测试需求:

测试设计:
因为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    http://www.baidu.com    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
上一篇下一篇

猜你喜欢

热点阅读