Hooking Up Automated Unit Tests (a simple approach, if one is to be had)


Jordan S.

Okay so I've finally "seen the Light" about writing automated unit tests
ahead of time.

Question: What is a very simple approach that I can use to setting up
automated unit tests, considering that I don't want to (1) embed them in
production code at all (even with compiler directives to ignore them for
release builds); and (2) I don't want to jump into a full-blown unit testing
framework quite yet (like NUnit).

I'm looking to set up a very simple way to hook up automated unit-tests just
so I can get the hang of it and demonstrate it to my colleagues as a "here's
how simple it can be" demo. After that I'd likely be able to appreciate
NUnit (or similar) and sell others on the idea of adopting such a mainstream
testing framework.

We're developing all types of .NET application types except for mobile; Web
using VS 2008.

And yes, I have goodled this, but what I have come up with is hits for the
big frameworks... not helpful for my objective of seeing how simple it can





I advise to get past the NUnit reluctance, and just start with it.

Here is a quick tutorial. (about as quick as it gets)


Which is basically...alot more simple than home brewing something.


This is a wise investment as well:

If the light has truly went off, you'd embrace all the hardwork already done
for you with NUnit.

The first URL can show you how simple it is.


I think most developers do the "test" code to begin with, they just put it
in commandButtons on dummy winforms applications.

This is a way to exercise a little discipline, and put it somewhere that it
makes sense.


Here are some ready made samples as well:


You never "embed" into production code the unit tests.
They should be in their own assembly, and only reference your (mainly)
business logic layer.

I submit that the "light going off" means adopting NUnit or the MS
Since NUnit is FREE (and MS is $$$ in VS2005 ) ( the MS UnitTesting was
advertised as free in VS2008 Pro)...
NUnit would be a great start.

Just because MS makes it, doesn't always make it better.
Aka, my personal preference is still NUnit.


Good luck.




i'd recommend to start with TestDriven.net and if u have alot of legacy code
to deal with, u can go with using TypeMock to mock ur dependent classes

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question