开发者

How do TDD and BDD relate to each other in Rails 3?

Im a beginner when it comes to TDD and BDD.

This is what I know:

To use TDD in Rails I use it's built-in unit-, functional and integration tests.

To use BDD in Rails I use Cucumber.

So are 开发者_运维技巧these two different techniques that shouldn't be used together?

If I use TDD, then I shouldn't use BBD/Cucumber and vice versa?

Please enlighten me on this topic.

Thanks


Not that I'm a genius at this but here's my humble answer.

Cucumber is great for outline the behavior of your site, incorporating the business solutions and the code together and developing the site properly from it.

Then after this is complete, you create Rspecs to test how data holds in your MVC. Rspec is great for models.

I've been recommended using Factory-Girl for testing controllers.

In conclusion, using all of these provides a very rounded series of tests to ensure that first your business solutions are being met, and second that your architecture can withstand the many angles that can be tested with rspec and factory-girl.


I've found that getting the right mix of what to when and why was the toughest part, given that there is often too much information on the net. A good blog post is Outside in BDD which takes you on a journey of testing using Cucumber and RSpec.

The author, Sarah Mei, explains the flow that a developer would undertake to use BDD/TDD and highlights some caveats on testing Controllers, Models and Views.

I tend to agree that Rspec is good for the models, more so when you have custom behaviour that is beyond what Rails gives you out of the box. This comes out in the RSpec & Cucumber books, it's just that it takes a while to find that gem of information about testing what, when and why !

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜