我想用cucumberjs写一个烟雾测试。我对黄瓜很新,不知道如何为复杂的过程编写场景。
我想检查的过程:
我不确定我需要创建多少个场景,一个用于全部,或者两个(一个用于登录页面重定向,另一个用于登录)或更多?
如果我写一个,可能是:
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'
不流利,有没有更好的表达方式?