gpt4 book ai didi

grails - 结构登录成功和失败功能

转载 作者:行者123 更新时间:2023-12-02 15:34:25 24 4
gpt4 key购买 nike

我刚开始使用Cucumber,而是在Grails 2.1.1应用程序中使用了Geb。我已经进行了第一个测试,测试了登录是否成功。

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 "user_10001" and "10001"
Then I see the dashboard

Given(~'^I access the login page$') {->
to LoginPage
at LoginPage
}

When(~'^I enter "([^"]*)" and "([^"]*)"$') { String username, String password ->
page.add(username, password)
}

Then(~'^I see the dashboard$') {->
at DashboardPage
}

Then(~'^I see an error message on the login page$') { ->
at LoginPage
}

这很好。我还想测试登录失败时会发生什么。我意识到这是另一种情况,但这是另一种功能吗?还是在同一功能上有其他场景?任何指导将不胜感激。

最佳答案

功能是一项功能。将方案划分为一个以上功能的唯一原因是使文件长度减少,并使有关功能的信息更易于搜索。

您的方案是身份验证功能的一部分。但是,如果您有很多与身份验证相关的功能(几个登录页面,忘记密码,SMS /电话确认),则可以将身份验证功能分为放置在身份验证文件夹中的多个功能文件。这取决于您的应用

我认为,无论哪种情况,成功和不成功的登录都更适契约(Contract)一文件。

另外,您的情况对我来说有点脆弱,势在必行。阅读以下:

  • Imperative vs Declarative Scenarios in User Stories
  • Refactored example from Cucumber book

  • 我会这样写:
    Scenario: Login
    Given I'm at login page
    When I login with valid credentials
    Then I see the dashboard

    关于grails - 结构登录成功和失败功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14087502/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com