posts - 103, comments - 4, trackbacks - 37

My Links

News

Tag Cloud

Archives

Parameterized Unit Tests

This is older, but Microsoft has a research paper about Parameterized unit tests. It's an interesting concept. Let's say you have a method that has a few extremes that need to be tested - let's try a simple example of multiplication. You would want to test something multiplied by 0. You'd want to test an overflow situation. Then, you'd want to test multiplying by a single negative number. Then maybe two negative numbers.

You get the idea. I listed out 4 tests above, but there could be many more. If you were to write unit tests now, you'd write 4 separate tests that all do the same thing - multiply two numbers together and check the result against a known result.

That's repetition. What if you could have a unit test that took three parameters - two numbers to multiply by, and a result. Then you feed the engine an input file - XML or something like that - and have it automatically run all cases of your unit test - and all you did was write one test.

I found this via Alan Dean, over at dotNetJunkies, and he seems to think it's a good idea, and that Nunit should look at implementing it. I wonder if they will.

Print | posted on Sunday, August 21, 2005 2:00 PM |

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: