views:

58

answers:

1

What I mean by that is, which tools are for unit testing, which for BDD, is there even a clear divide?

I'm just learning Ruby from C#, and the tools I'm familiar with there are xUnit-style for pure unit testing/TDD, and Cucumber/SpecFlow for BDD/integration testing. Of course, you can use unit testing tools for integration testing if you want to.

The main testing tools I've come across for Ruby are Test::Unit, RSpec, and Cucumber (there are obviously plenty more but these seem to be the most popular, and hence probably a good bet to start off with).

I'm not looking for a long list of tools here - if there's a main contender I've missed then please tell me, but I'd rather keep it simple at this stage than start using 'Tool Z beta with the Library X extensions running on the MegaChode platform' or whatever. I'm only a poor confused .Net guy, after all!

It's clear that Test::Unit was designed for unit testing, and Cucumber is for BDD. But I'm not sure about RSpec - some people seem to use it as a low-level unit testing tool, and others for higher-level BDD. At the same time, some people seem to use Test::Unit (and similar) with additional libraries for BDD.

To give you an idea of where I'm coming from, the way I see it is that you can write more functional, testable specifications (which a business guy might understand) with your BDD tool and then do low-level, developer-focussed TDD with your unit testing tool as you implement the functionality required for your Cuke (or whatever).

Is there a generally accepted way of doing these things in Ruby, or do I need to forget about such a crazy notion and use whatever seems to do the job?

Cheers, Grant

+4  A: 

I think most Rubyists have standardized on RSpec rather than Test::Unit for testing. If you're doing Rails apps, there is RSpec-Rails and then Cucumber you can layer on top of it.

Grab a copy of The Rspec Book @ http://www.pragprog.com/titles/achbd/the-rspec-book

ryw
i agree with ryw. having come from the same c#/testing background as you, Grant, you should find rspec to be very easy to work with. it has had a significant influence on how i approach testing in C#, too.
Derick Bailey