如何组织cucumberjs场景的登录过程?

时间:2015-04-25 13:21:48

标签: cucumber bdd

我想用cucumberjs写一个烟雾测试。我对黄瓜很新,不知道如何为复杂的过程编写场景。

我想检查的过程:

  1. 我是未签约用户
  2. 我打开' / my-home'在浏览器中
  3. 它会重定向到' / login?continue = / my-home'
  4. 页面上会有一个登录表单
  5. 我输入了用户名和密码,然后按'登录'按钮
  6. 如果已登录,则会重定向到' / my-home'
  7. 我可以看到我的名字' Freewind'在页面上
  8. 我不确定我需要创建多少个场景,一个用于全部,或者两个(一个用于登录页面重定向,另一个用于登录)或更多?

    如果我写一个,可能是:

    Scenario: Login to my home
      Given I'm an unsigned user
        And I open '/my-home' in the browser
        And it will redirect to '/login?continue=/my-home'
        And there will be a login form on the page
       When I input my username and password
        And press 'login' button
       Then it will redirect to '/my-home'
        And I can see my name 'Freewind' on the page
    

    如果我写两个,可能是:

    Scenario: Login page redirection
      Given I'm an unsigned user
       When I open '/my-home' in the browser
       Then it will redirect to '/login?continue=/my-home'
        And there will be a login form on the page
    
    Scenario: Login to my home
      Given I opened the login url '/login?continue=/my-home'
       When I input my username and password
        And press 'login' button
       Then it will redirect to '/my-home'
        And I can see my name 'Freewind' on the page
    

    哪一个更有意义?还有更好的方法吗?

    我发现Given I opened the login url '/login?continue=/my-home'不流利,有没有更好的表达方式?

0 个答案:

没有答案