Behavior-driven development(BDD)

什么是BDD

看看WiKi: http://en.wikipedia.org/wiki/Behavior_Driven_Development

BDD is a second-generation, outside–in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.


Programmer-domain examples and behavior

The same principles of examples, using contexts, events and outcomes are used to drive development at the level of abstraction of the programmer, as opposed to the business level. For instance, the following examples describe an aspect of behavior of a list:

Example 1: New lists are empty

  • Given a new list
  • Then the list should be empty.

Example 2: Lists with things in them are not empty.

  • Given a new list
  • When we add an object
  • Then the list should not be empty.
下面介绍一个JBehave框架

请看这篇PPT:http://www.slideshare.net/shadrik/bdd-with-java-8323915

IBM之前的一篇http://www.ibm.com/developerworks/cn/java/j-cq09187/index.html

摘要:

JBehave 是用于 Java™ 平台的一个 BDD 框架,源于 xUnit 范例。正如您所料,JBehave 强调应该 这个词,而不是测试。和 JUnit 一样,您可以在自己喜欢的 IDE 中,或者通过偏爱的构建平台(例如 Ant)运行 JBehave 类。

JBehave 允许以 JUnit 的方式创建行为类;但是,在 JBehave 中,不需要扩展任何特定的基类,并且所有行为方法都需要以 should而不是 test 开头,如清单 1 所示。


清单 1. 用于栈的一个简单的行为类
                
public class StackBehavior {
 public void shouldThrowExceptionUponNullPush() throws Exception{}
 public void shouldThrowExceptionUponPopWithoutPush() throws Exception{}
 public void shouldPopPushedValue() throws Exception{}
 public void shouldPopSecondPushedValueFirst() throws Exception{}
 public void shouldLeaveValueOnStackAfterPeep() throws Exception{}
}



还有一个项目:https://github.com/goldoraf/bdd-webdriver

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值