Review of Roy Osherove’s review.
Posted by Vadim on March 20, 2009
I liked the video and many points Roy makes are very valid. However, let me concentrate on the things I didn’t like.
- During the video Roy complains how tired he is because it’s 2 AM and he has to record the video. Who’s fault is that? I’m as a viewer prefer for my presenter to be fresh and energetic. Roy, I want to you to teach me, I don’t want to know that you’re tired and that your wife and the kid sleep in another room.
- Roy also criticize people who created a test with multiple asserts. In that particular case the test method had two asserts. I personally don’t see big problem to use more than one Assert as long as the test name describe what is tested. He also gives viewers a doctor analogy which I fail to find appropriate.
- I was very surprised when after complaining about multiple asserts in a single unit test, Roy recommends using RowTest feature of MbUnit / NUnit. Roy, how do you describe what is the difference between the first row and second row tests? About three years ago when I was a rookie in TDD world, I switched to MbUnit from NUnit because of RowTest attribute. NUnit didn’t have this feature at the time. However, I stopped using RowTest in my unit tests because it’s not clear what is tested. However, I still use this RowTests for my integration tests.
Here are couple of reasons why I stopped using RotTest attribute in my unit tests.
a. Let assume that you have a test that fails if a value is null or empty string. Here’s an example:
[Row("")] [Row(null)] public void UserName_property_should_faile_when_value_is_empty_or_null(string userName)
The problem is that when one of row test fails, it’s hard to see which one failed.
b. I use TestDriven.NET. When you run Row tests, TestDriven.NET executes all the row tests. To execute only one row I had to comment out all the other rows.
Instead of example above, I prefer to create two tests like this:
[Test] public void UserName_property_should_faile_when_value_is_empty() [Test] public void UserName_property_should_faile_when_value_is_null()
Roy, no hard feelings. I personally believe that you are doing a great job of educating people of better development practices. I myself learned a lot from you. Just don’t talk like Roy’s way is the only way.