我的cucumber的实践

确定Story标题的时候使用行为+对象的格式

例如: 

  • Feature:Login to the site #这就是一个用户登录的一个功能
  • Feature:withdraw cashes #提款功能
  • Feature:publish an article #发布文章

就像每次使用git commit的时候一样,这样的一个组合,体现一个功能,在代码实现的时候,知道要完成什么才算达到目的。

每个scenario的名字可以才用某个对象的不同状态来描述,强调sceanrios 之间的不同

例如

  • scenario: user is invalid 
  • scenario: user is valid
  • scenario: password is invalid
  • scenario: account is empty 
  • scenario: articles list is empty

 

完整实例:

实例1: login_to_the_site.feature

Feature: login to the site

    As a site's user    #角色扮演

    I want to login to the site    #功能需求

    So that I can use the site's apps

    Scenario:    accout is valid

        Given the user name "valid_account" 

        And the password "123123"

        When the authenticator is requrested

        Then the authenticator should return "pass"

    Scenario: account is invaild

        Given the user name "invalid_account"

        And the password "123123"

        When the authenticator is requrested

        Then the authenticator should raise "invalid account" exception

 实例2:Publish an article

 Feature: publish an article

    As an author

    I want to publish an article

    So that others can read the article

    Scenario: article is valid

        Given title "valid title"

        And content "valid body"

        When i save the article

        Then the article' list should contain the article

你可能感兴趣的:(我的cucumber的实践)