mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge pull request #28621 from lkxed/20230207-3-How-the-Gherkin-language-bridges-the-gap-between-customers-and-developers
[手动选题][talk]: 20230207.3 ⭐️ How the Gherkin language bridges the gap between customers and developers.md
This commit is contained in:
commit
3f484eee5d
@ -0,0 +1,91 @@
|
||||
[#]: subject: "How the Gherkin language bridges the gap between customers and developers"
|
||||
[#]: via: "https://opensource.com/article/23/2/gherkin-language-developers"
|
||||
[#]: author: "David Blackwood https://opensource.com/users/david-blackwood"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
How the Gherkin language bridges the gap between customers and developers
|
||||
======
|
||||
|
||||
Communicating with software developers can often be a burdensome task, especially when people lack technical knowledge and technical vocabulary. This is why project managers often use [user stories][1] and the versatile system metaphor_._
|
||||
|
||||
You can assist communication further by utilizing technology designed to facilitate discussions between a project's stakeholders and developers.
|
||||
|
||||
### The Cucumber framework
|
||||
|
||||
Cucumber is an open source framework that enables the creation of automated software tests using an easy-to-write and common language_._ It's based on the concept of [behavior-driven development (BDD)][2], which dictates that creating software should define how a user wants an application to behave when specific conditions are true.
|
||||
|
||||
The Cucumber framework isn't "technology" in the modern sense. It's not a collection of bits and bytes. Instead, it's a way of writing in natural language (English, in the case of this article, but so far Gherkin has been translated to over 70 languages). When using the Cucumber framework, you aren't expected to know how to read or write code. You only need to be able to write down ideas you have about how you work. You should also document how you want technology to work for you, using a set of specific terms and guidelines.
|
||||
|
||||
### What is the Gherkin language?
|
||||
|
||||
Cucumber uses Gherkin as a means to define use cases. It's primarily used to generate unambiguous project requirements_._ In other words, its purpose is to allow users to describe precisely what they require software to do, leaving no room for interpretation or exception. It helps you think through the process of a transaction with technology and then helps you write it down in a form that translates into programmer logic.
|
||||
|
||||
Here's an example:
|
||||
|
||||
```
|
||||
Feature: The Current Account Holder withdraws money
|
||||
Scenario: The account in question is not lacking in funds
|
||||
Given that the account balance is £200
|
||||
And the debit card is valid
|
||||
And the cash machine contains enough money
|
||||
When the Current Account Holder requests £50
|
||||
Then the cash machine dispenses £50
|
||||
And the account balance is £150
|
||||
And the debit card is returned
|
||||
```
|
||||
|
||||
As you can see, this is a highly specific scenario in which an imaginary user requests £50, and the ATM provides £50 and adjusts the user's account balance accordingly. This scenario is just one part of an ATM's purpose, and it only represents a specific component of a person's interaction with a cash machine. When a programmer is given the task to program the machine to respond to a user request, this clearly demonstrates what factors are involved.
|
||||
|
||||
#### What are Gherkin keywords?
|
||||
|
||||
The Gherkin syntax makes use of five indispensable statements describing the actions needed to perform a task:
|
||||
|
||||
- **Feature**: denotes a high-level description of any given software function
|
||||
- **Scenario**: describes a concrete _example_
|
||||
- **Given**: explains the initial context of the system
|
||||
- **When**: specifies an event or action
|
||||
- **Then**: describes an expected outcome, or a result
|
||||
- **And (or but)**: increases text fluidity
|
||||
|
||||
By making use of these simple keywords, customers, analysts, testers, and software programmers are empowered to exchange ideas with terminology that's recognizable by all.
|
||||
|
||||
### Executable requirements and automated testing
|
||||
|
||||
Even better, _Gherkin requirements are also executable._ This is done by mapping eachand every keyword to its intended (and clearly stated) functionality. So, to keep with the example above, anything already implemented could automatically be displayed in green:
|
||||
|
||||
```
|
||||
When the Current Account Holder requests £50*
|
||||
Then the cash machine dispenses £50*
|
||||
And the account balance is £150
|
||||
And the debit card is returned
|
||||
```
|
||||
|
||||
By extension, Gherkin enables developers to translate requirements into testable code. In practice, you can use specific phrases to check in on your software solutions! If your current code isn't working properly, or a new change has accidentally caused a software error (or two or three) then you can easily pinpoint problems before proceeding to repair them.
|
||||
|
||||
### Conclusion
|
||||
|
||||
Thanks to the Gherkin syntax, your customers will no longer be in a pickle. You can bridge the divide between businesses and developers and deliver outstanding products with greater confidence than ever before.
|
||||
|
||||
Find out more about Gherkin by visiting the [Cucumber website][3] or its [Git repository][4].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/23/2/gherkin-language-developers
|
||||
|
||||
作者:[David Blackwood][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/david-blackwood
|
||||
[b]: https://github.com/lkxed/
|
||||
[1]: https://softwareplanetgroup.co.uk/user-stories-bridging-the-gap-between-customers-and-developers-updated/
|
||||
[2]: https://opensource.com/article/19/2/behavior-driven-development-tools
|
||||
[3]: https://cucumber.io/docs/gherkin/
|
||||
[4]: https://github.com/cucumber/docs
|
Loading…
Reference in New Issue
Block a user