Ten T.D.D. Commandments


Update* A while ago I thought it was cool to use the file system during a test but a little bunny taught me otherwise. I’ve removed a redundant commandment as well.

Inspired by Ashcroft… not that Ashcroft but this one.

Ten Commandments of Unit Tests

1. I am the class being tested. Thou shalt not test any other class but me.
2. Thou shalt NOT write implementation without a unit test.
3. Thou shalt ensure the bar is red before any code is written.
4. Thou shall NOT write two tests which depend upon each other
5. Thou shall NOT test private methods.
6. Thou shall NOT access files during unit tests.
7. Thou shalt always refactor both test and implementation code after every green bar.
8. Thou shall NOT worship (or test) any false classes (mocks).
9. Thou shall NOT define more than one behavior in a unit test.
10. Thou shall NOT commit code without green bars on all tests.

2 thoughts on “Ten T.D.D. Commandments

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