BDD:源于TDD而胜于TDD
发布时间:2020-12-13 20:40:16 所属栏目:百科 来源:网络整理
导读:什么是BDD? Behave Driven Development(行为驱动开发?) 为什么要有BDD? TDD其实是测试行为的 TDD的测试用例太专业,业务和需求人员看不懂 TDD不知道哪些代码需要写测试,怎么写? 我们要写“规范(specifications)”,所有人都可以读懂,甚至业务人员可
什么是BDD?
Behave Driven Development(行为驱动开发?) 为什么要有BDD?
BDD告诉我们我们要写spec而不是Test,我要做的事是“Specification,not Verification”。 说了这么多,BDD到底什么样子?BDD开发需要一个Behaviour Specification Framework,就像TDD需要xUnit,这里的例子来自RSpec,一个如不要的Behaviour Specification Framework。(I love ruby!)
context
"
BDDframework
do
setup @bdd_framework = BddFramework. new end specify shouldbeadoptedquickly @bdd_framework.should_be_adopted_quickly end specify shouldbeintuitive @bdd_framework.should_be_intuitive end end RSpec还有一个rails的插件,可以和rails良好协作,例子代码: Auser(ingeneral)
万恶的csdn来个ruby语法加亮都没有。 参考网址:http://behaviour-driven.org/ http://rspec.rubyforge.org/ http://www.lukeredpath.co.uk/2006/8/29/developing-a-rails-model-using-bdd-and-rspec-part-1 setup @user User. shouldbeinvalidwithoutausername @user.email ' joe@bloggs.com @user.password abcdefg @user.should_not_be_valid @user.errors.on(:username).should_equal isrequired @user.username someusername @user.should_be_valid end specify shouldbeinvalidwithoutanemail joebloggs @user.should_not_be_valid @user.errors.on(:email).should_equal shouldbeinvalidwithoutapassword @user.should_not_be_valid @user.password @user.should_be_valid end end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |