Thursday, November 26, 2009

Unit testing in Visual Studio Express

I try to use a test driven approach when I develop. During the years I have gained a lot of positive feelings from unit tested code. Using it in small hobby projects sometimes add a lot of work without the benefit of having unit tests in place for later changes. Although I have decided to use it whenever I code, just to keep learning the practice of test driven development.

Reporter: But Magnus, why did you implement your own unit test framework? There are a lot of them out there!
- Good question. I checked out two of the options for .NET
NUnit, the mother of all unit test frameworks on .NET platform.
I have used this for quite a long time with an postbuild option to run tests as command line. Although with express edition you get a separate test runner and there is a twist to get debug to work with your unit tests.

ExpressUnit, a newcomer for the express edition.
It looked promising and it might probably have solved my problems, but I didn't fall for it and when the GUI test runner showed up I decided to try out my own way.

Reporter: And...
- Being a long time NUnit user I felt that it was time to find a easier way to do unit testing in express edition. ExpressUnit gave me some ideas on that it should be possible. My developer brain then turned into action and it didn't last long before I found myself in a really interesting project of creating my own framework.

Reporter: So, what is the result?
- As every good unit test names are already used it became grimmyunit. Main feature is that it's very integrated into my own development process. I create two projects, one for the unit tests and another one for my production code. Then I write tests and implement code, to run the tests I simply rebuild the test project. The output is displayed in Visual Studios Error output as clickable information. So if I have a failing unit test I can simply click on the error and the code is shown.

No comments:

Post a Comment