Nose: TDD in Python
October 19, 2008 § 1 Comment
Test Driven Development is awesome. So awesome, you cannot NOT use this methodology.
Here’s why I think TDD is awesome:
- When implementing a function, and then create its unit test immediately, I have strong confident that my function works because unit test passed.
- The same thing happen when creating inheritance structure, I know exactly what instance contains which property because unit test passed.
- When I have my stupid moment, I can confidently refactor ALL of the existing codes, because unit test will correct me if I missed something.
That being said, for Python, there’s Nose.
It’s a unit testing framework that doesn’t get in the way. It gathers unit tests based on certain naming conventions. Any functions or classes that match the following ((?:^|[b_.-])[Tt]est) will be run as unit test. It’s that simple.
Installing nose is as simple as installing any other python module. Do: easy_install nose
With the right unit testing framework, you can put together unit tests quickly. So, there’s no reason not to do it.