News for hackers. Stuff that matters.
Re:Test-Driven Django Tutorial by hjwp3 on Monday May 21, 2012 @09:22AM (#4002685)
thanks!

re: the first unit test, and the saving & retrieving of records -- i know this feels a bit like "testing django", but the real intention is to test that we've set up our model with the right fields.

The alternative would be to test defaults - instantiate a model, and assert that it has attributes with the correct names for the model fields we've defined, and the correct default values... I suspect that is the more common pattern, and it's certainly what we do at work. I think it can be seen as better in the sense that it has less of a dependency on Django. OTOH, the saving and retrieving provides a useful introduction to the ORM, so it's useful for the wider tutorial. It's also a bit more in the spirit of testing desired behaviour... So, pros and cons on each side really...

There are no comments on this comment yet.