tags:

views:

142

answers:

1

Copied from the site http://github.com/notahat/machinist/

Machinist makes it easy to create test data within your tests. It generates data for the fields you don't care about, and constructs any necessary associated objects, leaving you to only specify the fields you do care about in your tests

A simple blueprint might look like this:

Post.blueprint do
  title  { Sham.title }
  author { Sham.name }
  body   { Sham.body }
end

You can then construct a Post from this blueprint with:

Post.make

When you call make, Machinist calls Post.new, then runs through the attributes in your blueprint, calling the block for each attribute to generate a value. The Post is then saved and reloaded. An exception is thrown if Post can't be saved.

+1  A: 

I looked through the whole Python Testing Tools Taxonomy page (which has lots of great stuff) but didn't find much of anything like Machinist.

There is one simply script (called Peckcheck) that's basically unit-testing-with-data-generation, but it doesn't have the Blueprinting and such... so you might say it's just a Sham :)

ewall
I did not know about the Testing Tools Taxonomy page. I'll check it out some more.
Jörgen Lundberg