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.

References:

Advertisements

Tagged: , ,

§ One Response to Nose: TDD in Python

  • Jordan says:

    Except that you don’t create the function and then immediately implement the test, it’s the other way around: You write the test FIRST, obviously failing, and then add just enough code to make it pass.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading Nose: TDD in Python at RAPD.

meta

%d bloggers like this: