您如何通过声明式验收测试捕获需求? [英] How do you capture requirements with declarative acceptance tests?

查看:19
本文介绍了您如何通过声明式验收测试捕获需求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我正在努力帮助我的团队组织一个新的移动应用项目.我们选择遵循 BDD(另见 BDD 定义) 以获取简单的英语要求,这些要求形成利益相关者和开发人员之间针对每个单独用户故事的合同.

I am trying to help my team organize for a new mobile app project. We have chosen to follow BDD (see also BDD definition) in order to capture plain English requirements that form a contract between stakeholders and developers for each individual user story.

我们使用验收测试来记录每个用户故事的要求.验收测试是在 sprint 计划之前编写的.开发人员在 sprint 计划期间改进和添加测试.

We use the acceptance tests to document each user story's requirements. Acceptance tests are written before sprint planning. Developers refine and add to the tests during sprint planning.

我们将 Acceptance Criteria 定义为规则列表(例如:输入验证、默认值等),将 Acceptance Tests 定义为 Cucumber 场景列表.我们计划使用 Calabash 进行移动测试.

We define Acceptance Criteria as a list of rules (eg: input validation, default values, etc) and Acceptance Tests as a list of Cucumber scenarios. We plan on using Calabash for mobile testing.

我觉得验收标准/测试是更灵活的,因此是更正式的需求文档的更好解决方案.

I feel acceptance criteria/tests are a more agile and therefore better solution to more formal requirements documents.

我觉得我找到了一个有效的解决方案,但我想了解其他人如何收集需求和编写验收测试.

I feel I have found an effective solution fo, but I would like to understand how others are collecting requirements and writing acceptance tests.

问题

命令式 vs 声明式 测试步骤.我倾向于命令式,因为开发人员必须知道可交付的用户故事是什么样的.

There is a debate in the Cucumber community of imperative vs declarative test steps. I lean toward imperative, because a developer must know what a deliverable user story looks like.

我不觉得 UI 耦合又名脆弱测试是一个问题.有多种方法可以将 UI 与测试分离(例如:页面对象).我也不认为有详细的步骤会让非技术利益相关者难以理解(除非他们不知道如何使用网络浏览器或移动设备,但这是一个单独的问题).

I do not feel UI coupling aka brittle tests is an issue. There are ways to decouple the UI from the test (eg: page objects). I also do not feel that having detailed steps make it hard for a non-technical stakeholder to understand (unless they don't know how to use a web browser or mobile device, but that's a separate issue).

我可能盗用了术语验收测试".在我的使用中,验收测试与单元测试不在同一范围内.我将验收测试视为高级集成测试.

I may be misappropriating the term "Acceptance Test". In my use, an acceptance test is not on the same level of scope as a unit test. I view an acceptance test as a high level integration test.

示例

  • 作为客人
  • 我要登录
  • 访问应用功能

命令式测试

  • 场景:有效登录
    • 鉴于我在登录"屏幕上
    • 当我在电子邮件"中输入email@domain.com"时
      • 我在密码"中输入密码1"
      • 然后我点击登录"

      声明式测试

      • 场景:有效登录
        • 假设我有一个有效的帐户
        • 然后我就可以登录了

        这两者都可以涵盖相同的功能并且后者更短,但它并没有说明我是否可以使用用户名、电子邮件或 facebook/twitter/google/etc 帐户登录.仅仅编写解决方案是不够的

        These both can cover the same functionality and the latter is shorter, but it does not say if I can login with a username, email or facebook/twitter/google/etc account. It's just not enough to actually code a solution

        问题

        您如何通过声明性步骤捕获功能的需求?

        How do you capture the requirements for a feature with declarative steps?

        推荐答案

        问题写得很好!

        您如何使用声明式捕获功能的需求步骤?

        How do you capture the requirements for a feature with declarative steps?

        功能的要求记录在步骤定义中.

        The requirements for a feature are recorded in the step definitions.

        因此在您的命令式示例中:

        Hence in your imperative example:

        When I enter "email@domain.com" in "email"
        And I enter "password1" in "password"
        And I tap "login"
        

        这可以通过将其重写为声明性的:

        this could be made declarative by re-writing it as:

        Given I login using valid credentials
        

        导航到有效帐户的步骤(即实施定义有效"含义的接受标准)然后可以在此场景声明的步骤定义中实施.这同样适用于相反的情况,即

        The steps to navigate to a valid account (i.e. implementing the acceptance criteria which defines what "valid" means) can then be implemented in the step definition for this scenario statement. The same will apply for the opposite scenario i.e.

        Given I login using invalid credentials
        

        同样,满足验收标准的实现此场景的步骤可以在底层步骤定义中实现.

        Again, the steps to implement this scenario which satisfy the acceptance criteria can be implemented in the underlying step definition.

        采用这种声明性方法意味着您失去了功能的(必要的)要求(即需要执行哪些确切步骤),使企业更难确切地了解这些场景是什么只需阅读功能文件即可.但是,您得到的好处是测试变得不那么脆弱了,因为完成任务的具体步骤记录在步骤定义中,并且此步骤定义可以在许多功能之间共享.

        Taking this declarative approach means that you lose the (imperative) requirements from the feature (i.e. what exact steps need to be performed), making it harder for the business to see exactly what these scenarios are doing from just reading the feature file. However, what you gain is that the tests become less brittle, as the specific steps to achieve a task are recorded in the step definition, and this step definition can be shared amongst many features.

        在我的公司,我们也面临同样的问题,我们发现在某些情况下使用命令式比使用声明式更好,反之亦然.例如,在您的情况下,构成鉴于我有一个有效帐户"的步骤可能会在许多功能中使用,因此使其具有声明性是合理的.但是,如果您有一个输入许多不同字符串值的功能,那么在这种情况下,最好以命令方式编写它们.

        At my company we wrestle with the same concerns, and we find that in some cases it's better to use imperative rather than declarative, and vice versa. For example, in your case the steps which make up "Given I have a valid account" may be used in many features, so making it declarative is rational. However if you have a feature where many different string values are inputted, then in that case it's probably best to write them imperatively.

        课程用马!"

        从 SO 社区看到这个问题的其他答案会很有趣.

        It'll be very interesting to see other answers to this question from the SO community.

        这篇关于您如何通过声明式验收测试捕获需求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆