简体   繁体   English

BDD和单元测试

[英]BDD And Unit Testing

I have been doing TDD and was using it more as unit testing than to drive my design. 我一直在做TDD并且更多地使用它作为单元测试而不是驱动我的设计。 Recently I have read a lot about BDD; 最近我读了很多关于BDD的文章; now that I have a better idea about them both, I was trying to figure out how to use BDD and unit testing concurrently. 既然我对它们都有了更好的了解,我试图弄清楚如何同时使用BDD和单元测试。

For example I would drive my design using BDD, Dan North style, and lets say I am working on an app and I have a simple spec and I implement it. 例如,我会使用BDD,Dan North风格驱动我的设计,并且假设我正在开发一个应用程序,我有一个简单的规范,我实现它。 I have just enough bdd/spec to cover it. 我有足够的bdd / spec来覆盖它。 Now after I've re-factored it and am happy and it's passed as done for that spec, should I start writing Unit tests to cover all possible inputs, because that's what I did in TDD? 现在我重新考虑它并且很高兴并且它已经按照规范完成了,我是否应该开始编写单元测试以涵盖所有可能的输入,因为这是我在TDD中所做的?

I am the only developer in the company and everything is on my shoulders, although the other team do try to manual test the app, I would like to lower the defect rate. 我是公司唯一的开发人员,一切都在我的肩上,虽然其他团队确实尝试手动测试应用程序,但我想降低缺陷率。

Pick up "The RSpec Book". 拿起“RSpec书”。 The book uses Cucumber & RSpec. 这本书使用了Cucumber和RSpec。 Could easily be Cucumber & NUnit or something else though. 可以很容易地成为Cucumber&NUnit或其他东西。 Cucumber and BDD extend the red, green, refactor concept a level deeper. 黄瓜和BDD将红色,绿色,重构概念延伸到更深层次。

http://www.pragprog.com/titles/achbd/the-rspec-book http://www.pragprog.com/titles/achbd/the-rspec-book

Cucumber: http://cukes.info/ 黄瓜: http//cukes.info/
RSpec: http://rspec.info/ RSpec: http: //rspec.info/
NUnit: http://www.nunit.org/ NUnit: http ://www.nunit.org/
JUnit: http://www.junit.org/ JUnit: http//www.junit.org/

I agree. 我同意。 The RSpec Book book does a decent job of describing the "Outside - In" approach to development. RSpec Book book在描述“Outside-In”开发方法方面做得不错。 Cucumber (outside) helps describe the expected behavior (in terms that the user understands); 黄瓜(外部)有助于描述预期的行为(以用户理解的方式); and RSpec/*Unit (inside) helps to describe your class' behavior. 和RSpec / * Unit(内部)有助于描述你的班级行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM