It’s a one-line function that returns a constant. What could go wrong?

Here’s a function:

def get_foo():
    return None

Simple, right? I don’t need to unit test that. Except I did, because that method was part of a mixin:

class MyMixin(object):
    def get_foo():
        return None

And that mixin was attached to a class, which inherited from another class. And that parent class also inherited from a different mixin, that had a different implementation of get_foo(). So, if I had actually written the unit test against the class in question, I would’ve caught that error right away.

At least I had the sense to write the unit test when I was trying to figure out why things were failing in the functional testing.

Write the unit test. Just write it.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s