Trevor Berg: The Blog

Avatar

BDD with Shoulda

Over the past few days I’ve been looking at some of the plugins/frameworks that can be used with rails to improve testing. I came across this video of Tammer Saleh giving a presentation titled “BDD with Shoulda” at MountainWest RubyConf 2008.  He did a good job giving a brief intro to Shoulda, fixtures, and good testing practices.  For anyone who doesn’t know about Shoulda:

The Shoulda Rails plugin makes it easy to write elegant, understandable, and maintainable tests. Shoulda consists of test macros, assertions, and helpers added on to the Test::Unit framework. It’s fully compatible with your existing tests, and requires no retooling to use.   

Helpers – context and should give you rSpec like test blocks. In addition, you get nested contexts and a much more readable syntax.

Macros – Generate hundreds of lines of Controller and ActiveRecord tests with these powerful macros. They get you started quickly, and can help you ensure that your application is conforming to best practices.

Assertions – Many common rails testing idioms have been distilled into a set of useful assertions.

The presentation is a little over an hour long, but I think it’s definitely worth a watch.

BDD with Shoulda - Tammer Saleh at MountainWest RubyConf 2008

The Flawed Theory Behind Unit Testing

I came across an interesting blog entry by Michael Feather’s on how TDD and Clean Rooms relate to code quality. If you have a few minutes it’s definitely worth a read.

The Flawed Theory Behind Unit Testing by Michael Feathers

Continue