📜  软件工程中 BDD 与 TDD 的区别

📅  最后修改于: 2021-09-13 03:17:50             🧑  作者: Mango

1. 行为驱动开发(BDD):
行为驱动开发 (BDD) 是一种开发技术,它更多地关注软件应用程序的行为。主要是它创建了一个由于相应功能不存在而失败的可执行规范,然后编写可以使规范通过的最简单的代码,结果我们在系统中实现了所需的行为。实际上,这是一种开发人员参与其中的开发实践。

BDD过程:

  1. 编写应用程序的行为
  2. 编写自动化脚本
  3. 然后实现功能代码
  4. 检查行为是否成功,如果不成功则修复它
  5. 整理代码(可选)
  6. 对另一种行为重复这些步骤

2.测试驱动开发(TDD):
测试驱动开发 (TDD) 是一种开发技术,它更侧重于软件应用程序/产品功能的实现。主要是指编写一个由于指定功能不存在而失败的测试用例,然后更新可以使测试用例通过的代码,结果我们在系统中实现了该功能。实际上,这是一种团队方法,其中开发人员、客户和 QA 都参与其中。

TDD的过程:

  1. 添加测试用例
  2. 运行测试用例并观察测试失败
  3. 更新代码
  4. 再次运行测试用例
  5. 重构代码(可选)
  6. 对另一个测试用例重复这些步骤

BDD 与 TDD 之间的区别:

S.NO.

Behavior Driven Development

Test Driven Development

01. Behavior Driven Development is a development technique which focuses more on a software application’s behavior. Test Driven Development is a development technique which focuses more on the implementation of a feature of a software application/product.
02. In BDD the participants are Developers, Customer, QAs. In TDD the participants are developers.
03. Mainly it creates an executable specification that fails because the respective feature doesn’t exist, then writing the simplest code that can make the specification pass and as a result we get the required behavior implemented in the system. Mainly it refers to write a test case that fails because the specified functionality doesn’t exist and after that update the code that can make the test case pass and as a result we get the feature implemented in the system.
04. Its main focus is on system requirements. Its main focus is on unit test.
05. In BDD the starting point is a scenario. In TDD the starting point is a test case.
06. It is a team methodology. It is a development practice.
07. Here language used to write behavior/scenarios is simple English language. Here language is used is similar to the one used for feature development like programming language.
08. In BDD collaboration is required between all the stakeholders. In TDD collaboration is required only between the developers.
09. It is a good approach for project development which are driven by user actions. It is a good approach for projects which involve API and third-party tools.
10. Some of the tools used are  Cucumber, Dave, JBehave, Spec Flow,  Concordian, BeanSpec etc. Some of the tools used are  JBehave, JDave, Cucumber, Spec Flow, BeanSpec, FitNesse etc.