标签:
行为驱动开发(Behavior-Driven Development,简称BDD),是在测试驱动开发(Test-Driven Development,TDD)基础上发展而来的一种软件开发方法。TDD最大的弊端,是面对一大堆的功能需求和用例时,往往会感到无从下手。另一方面,由于TDD更侧重于测试本身,因此容易忽视对业务需求的表达,最终沉溺于琐碎细节而无法自拔。
与传统的软件开发方法相比,BDD的本质在于尽可能避免在需求描述、用例撰写、代码实现、测试等各环节衔接、转译过程中发生的信息丢失。为此,BDD以用例Use Case和示例Example为核心,借助Gherkin等一些特有概念和一系列BDD特有工具,以更贴近业务场景的方式,实现软件需求的完整实现。二者的比较如下图所示。
BDD的每个迭代可以表述为:
Gherkin,是BDD中用于描述特定业务场景示例Example,采取特定格式的文本。它较之需求规范Specification更具体明了,有点类似Use Case,但更具体生动。既可用作测试脚本,又可作为归档的内容。
Feature: Transferring money between accounts
In order to manage my money more efficiently
As a bank client
I want to transfer funds between my accounts whenever I need to
Scenario: Transferring money to a savings account
Given my Current account has a balance of 1000.00
And my Savings account has a balance of 2000.00
When I transfer 500.00 from my Current account to my Savings account
Then I should have 500.00 in my Current account
And I should have 2500.00 in my Savings account
标签:
原文地址:http://www.cnblogs.com/Abbey/p/4999634.html