Showing posts with label TDD. Show all posts
Showing posts with label TDD. Show all posts

Wednesday, 14 September 2011

TDD day with Roy Osherove

Had a great TDD (and unit test) course with Roy Osherove at my company yesterday.
Here are some things that caught my attention. I'm writing them down mainly for a reminder to myself.
1. Good test names
Good test names are everything! There is nothing wrong with that it may take hours(!) just to come up with a good name for the test. Don't start writing code for the test and make up a name for it later - spend time on the name instead! If you have a great name, writing the code for it will take minutes.
2. Refactor tests
This may sound obvious, but you often forget that even your tests needs refractoring. A test should only contain a couple of lines of code. It it doesn't it's a signal that you are writing a bad test. Maybe you're testing the wrong thing or testing to much or anything else. To help: see 1). ...or refactor!
3. No [SetUp]
Don't use setup. It destroys readability. Refractor instead. More reading: http://jamesnewkirk.typepad.com/posts/2007/09/why-you-should-.html
4. No [TearDown]
It's fine to use teardowns. But it's a signal that you are not writing unit tests, you are writing integration tests!

Maybe I'll update this post if I start to remember more things :-)