如何组织cucumberjs场景的登录过程?
我想用黄瓜做一个烟雾测试。我对cucumber很陌生,不知道如何为复杂的流程编写场景 我要检查的流程: 我是一个未签名的用户 我在浏览器中打开“/my home” 它将重定向到“/login?continue=/my home” 页面上将有一个登录表单 我输入用户名和密码,然后按“登录”按钮 如果登录,它将重定向到“/my home” 我可以在页面上看到我的名字“Freewind” 我不确定我需要创建多少个场景,一个用于所有,或者两个用于登录页面重定向,另一个用于登录,或者更多 如果我写一个,它可能是:如何组织cucumberjs场景的登录过程?,cucumber,bdd,Cucumber,Bdd,我想用黄瓜做一个烟雾测试。我对cucumber很陌生,不知道如何为复杂的流程编写场景 我要检查的流程: 我是一个未签名的用户 我在浏览器中打开“/my home” 它将重定向到“/login?continue=/my home” 页面上将有一个登录表单 我输入用户名和密码,然后按“登录”按钮 如果登录,它将重定向到“/my home” 我可以在页面上看到我的名字“Freewind” 我不确定我需要创建多少个场景,一个用于所有,或者两个用于登录页面重定向,另一个用于登录,或者更多 如果我写一个,它
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
如果我写两个,可能是:
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
哪一个更有意义?还有更好的办法吗
我发现如果我打开了登录url“/login?continue=/myhome”不流畅,有没有更好的方式来表达它?不要这样写场景。所有这些关于“如何”登录的详细信息都属于场景步骤定义和帮助器方法下面的代码。虽然一开始可能有点奇怪,但编写此功能的方法如下
Feature: Registered users can login
Background:
Given I am registered
Scenario: I log in
When I login
I should be logged in
之后,您可以编写其他场景,如
Scenario: I log in with the wrong password
然后,您可以编写有关未注册用户和注册的功能
在编写特性时,要像业务人员一样思考,而不是开发人员或测试人员。解释你想做什么以及为什么它很重要,忽略“如何”完成事情