写“何时然后何时给出"是否可以接受?在小黄瓜上测试? [英] Is it acceptable to write a "Given When Then When Then" test in Gherkin?

查看:95
本文介绍了写“何时然后何时给出"是否可以接受?在小黄瓜上测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用小黄瓜编写何时给予,何时给予"测试是否可以接受? 一个真实的示例如下所示:AllAllers.com

Is it acceptable to write a "Given When Then When Then" test in Gherkin? A real-life example is as follows all AllPlayers.com

Scenario: Successfully register a user
  Given I am on homepage
    And I am not logged into an account
  When I follow "create a new account"
    And I fill in "First Name" with "Bobby"
    And I fill in "Last Name" with "Bricks"
    And I fill in "E-mail" with "bbricks@example.com"
    And I select "Jun" from "Birthday Month"
    And I select "22" from "Birthday Day"
    And I select "1985" form "Birthday Year"
    And I select "Male" from "Gender"
    And I fill in "Password" with "123testing"
    And I fill in "Confirm Password" with "123testing"
    And I solve the captcha math problem
    And I click "Create new account"
  Then I should see "the user dashboard"
    And I should see the Registration Wizard
  When I push "Proceed to next step"
  Then the "First Name" field should contain "Bobby"
    And the "Last Name" field should contain "Bricks".

我知道它可以使用behat起作用,因此解析它不是问题.我只是想编写更好的测试.我可以先写一个,然后写And the Registration Wizard should be filled out with data,但这似乎不够具体...

I know it works using behat, so parsing it isn't a problem. I'm just trying to write better tests. I could write in the first then And the Registration Wizard should be filled out with data but that doesn't seem specific enough...

建议?

推荐答案

这取决于所写功能的目标受众.您到达的小黄瓜很可能不是由利益相关者撰写的(即,不是技术人员,但对公司和网站有既得利益的人). BDD实际上是关于需求和期望的 对话 -Gherkin是一种工具,它提供了一种标准/公认的方式,每个人都应该能够阅读并编写要求和期望;可以作为开发人员的自动化测试,也可以作为测试人员的测试脚本.

It depends on the target audience of the feature as written. It seems highly likely that the gherkin you've got there was not written with a stakeholder (i.e. somebody not-techie but has a vested interest in the business and the website). BDD is really about the conversation about requirements and expectations - and Gherkin is a tool which gives a standard/recognised way that everyone should be able to read that you can write the requirements and expectations; in a way that serves as automated tests for a developer and perhaps test scripts for a tester.

现在想让我的开发者脱下帽子-我要说的是,业务利益相关者宁愿阅读并轻松理解...

Trying to take my developer hat off now - I would say that a business stakeholder would rather read, and understand easily...

Scenario: Should be able to successfully register on website
    Given I am new to the website
    And I want to register for a user account
    When I go to the registration form
    And I complete all the required registration details correctly
    Then I will be registered on the website
    And I will be automatically logged in

您仍然可以在本规范的幕后建立相同的测试-但是该规范具有更大的读者群,这是任何人都应该理解的更容易理解的要求.我并不是说您所拥有的没有任何价值-远非如此.这将是一个非常有效的测试.但这是特定于开发人员的,并且与UI实现高度相关(如果重构/重新设计UI,则现在需要重构需求...).

You can still build the same test behind the scenes of this specification - but this specification has larger readership, it is a more easily understood requirement that anyone should understand. I'm not saying what you have got has no value - far from it. It will be a very valid test. But it is quite developer specific, and highly coupled to the UI implementation (if you refactor/redesign the UI, you now need to refactor your Requirements...).

我开始像您一样拥有大量的小黄瓜规格-有时我仍会使用它们.一旦您的测试框架建立了一点小知识,这就是编写数据驱动/可配置单元测试的一种非常不错的方式.而且它们对我的开发过程仍然具有很大的价值.但是我确实尝试将更纯"的规范与我的开发人员"的规范分开-而是文件夹和标签/类别.

I started off having plenty of gherkin specifications much like yours - and I still use them on occasion. Once your testing framework has built up a little gherkin is a really great way of kind of writing data-driven/configurable unit tests; and they still have great value to my development process. But I do try to separate the more "pure" specifications from my "developer" ones - but folder and tags/categories.

总的来说,我想我要得到的是...您拥有的是一个很好的测试",但是却是一个相当糟糕的要求".坚持下去吧!

I guess in summary what I'm getting at is... what you have is a great "test", but a fairly bad "requirement". Stick with it though!

这篇关于写“何时然后何时给出"是否可以接受?在小黄瓜上测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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