我使用的Grails 2.1.1黄瓜和创业板 我有一个包含2种情况的Auth.feature。 一个是成功认证,另一种是用于测试凭据无效。
我想我要工作了这一点的方法是让创业板注销,从第一个场景中,用户才可以运行第二个场景。 这是因为我考虑一步检查,以确保我在登录页面。 场景1个执行后,我是一个仪表板页面上。
我想我的问题是在完成方案或之前我(一)使用创业板退出的有效用户(b)是有没有办法把它重新开始的场景之间?
现在,我实现了(a)和它工作得很好。 只是想知道这是否是最佳的。
这是我的特点
Feature: login to system
As a user of the system
I want to log in to the application
so that I can use it
Scenario: login
Given I access the login page
When I enter valid credentials
Then I see the dashboard
Scenario: auth fail
Given I access the login page
When I enter invalid credentials
Then I see appropriate error messages
这里是我的盖布步骤
Given(~'^I access the login page$') {->
to LoginPage
at LoginPage
}
When(~'^I enter valid credentials$') {
page.add('user_10001@test.com', '10001')
}
Then(~'^I see the dashboard$') {->
at DashboardPage
}
Then(~'^I see an error message on the login page$') { ->
at LoginPage
}
When(~'^I enter invalid credentials$') { ->
page.add('baduser', 'paddpassword')
}
Then(~'^I see appropriate error messages$') { ->
at LoginPage
// check for error message
}