translated

This commit is contained in:
geekpi 2023-08-11 08:45:34 +08:00
parent 797b7afff5
commit 80c28dfd48
2 changed files with 91 additions and 91 deletions

View File

@ -1,91 +0,0 @@
[#]: 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: "geekpi"
[#]: 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

View File

@ -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: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Gherkin 语言如何弥合客户和开发人员之间的差距
======
与软件开发人员沟通通常是一项繁重的任务,尤其是当人们缺乏技术知识和技术词汇时。这就是为什么项目经理经常使用[用户故事][1]和多功能系统隐喻。
你可以利用旨在促进项目利益相关者和开发人员之间讨论的技术,进一步协助沟通。
### Cucumber 框架
Cucumber 是一个开源框架,可以使用易于编写的通用语言创建自动化软件测试。它基于[行为驱动开发 (BDD)][2] 的概念,该概念规定创建软件应定义用户希望应用在特定条件成立时如何表现。
Cucumber 框架并不是现代意义上的“技术”。它不是位和字节的集合。相反,它是一种用自然语言(在本文中为英语,但到目前为止 Gherkin 已被翻译成 70 多种语言)的写作方式。使用 Cucumber 框架时,你不需要知道如何读取或编写代码。你只需要能够写下你对工作方式的想法即可。你还应该使用一组特定术语和指南来记录你希望技术如何为你服务。
### Gherkin 语言是什么?
Cucumber 使用 Gherkin 作为定义用例的方法。它主要用于生成明确的项目需求。换句话说,其目的是允许用户准确地描述他们需要软件做什么,不留任何解释或例外的空间。它帮助你思考技术事务的过程,然后帮助你以可转化为程序员逻辑的形式将其写下来。
这是一个例子:
```
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
```
正如你所看到的,这是一个非常具体的场景,其中假设用户请求 50 英镑ATM 提供 50 英镑并相应地调整用户的帐户余额。此场景只是 ATM 用途的一部分,它仅代表人与提款机交互的特定组成部分。当程序员被赋予对机器进行编程以响应用户请求的任务时,这清楚地表明了涉及哪些因素。
#### Gherkin 关键字是什么?
Gherkin 语法使用五个不可或缺的语句来描述执行任务所需的操作:
- **Feature**:表示任何给定软件功能的高层次描述
- **Scenario**描述具体_示例_
- **Given**:解释系统的初始上下文
- **When**:指定事件或操作
- **Then**:描述预期输出或结果
- **And (或者 but)**:增加文本流畅性
通过使用这些简单的关键字,客户、分析师、测试人员和软件程序员能够使用所有人都能识别的术语来交换想法。
### 可执行的需求和自动化测试
更好的是_Gherkin 要求也是可执行的_。这是通过将每个关键字映射到其预期且明确说明的功能来完成的。因此为了与上面的示例保持一致任何已经实现的内容都可以自动显示为绿色
```
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
```
通过扩展Gherkin 使开发人员能够将需求转换为可测试的代码。在实践中,你可以使用特定的短语来检查你的软件方案! 如果你当前的代码无法正常工作,或者新的更改意外导致软件错误(或两个或三个),那么你可以轻松查明问题,然后再继续修复它们。
### 结论
得益于 Gherkin 语法,你的客户将不再陷入困境。你可以弥合企业和开发人员之间的鸿沟,并比以往更有信心地交付出色的产品。
通过访问 [Cucumber 网站][3]或其 [Git 仓库][4]了解有关 Gherkin 的更多信息。
--------------------------------------------------------------------------------
via: https://opensource.com/article/23/2/gherkin-language-developers
作者:[David Blackwood][a]
选题:[lkxed][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者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