Follow @RoyOsherove on Twitter

Doing Test Driven Development with no DLLs

Doing test driven development often(well, practically always) entails testing against a class library in your tests. It's just the easiest way to test functionality of objects (you need to reference those objects somehow, right?) so, most of the time you would create a test project and a tested library project before you ever create a GUI or a console application that uses that library.
But what happens when you have a very small project? say, a very simple console application with a very small set of functionality? Well, in the TDD manner you would have the console app built along with a library project that contains the classes that do the functionality. But it may seem a bit like overkill to have 3 separate projects for a such a simple task. Or maybe the customer will not want to distribute the console app along with a dll for something so simple as say... renaming files in the directory based on some simple business logic. Maybet he requirement is that the user should only have to copy one exe file into the directory and run it with no hassles.
 
So.After all this text, what do you do when you can't use a library project for a very simple functionality?
 
You don't create a library project. Instead you create the necessary class(es) in your console app.
Then you link to those class files from your test project:
 
“MyTestProject->Add existing files->select the class file-> open the small menu on the “open” button and choose “link”.
 
Now you have a physical reference to the classes but you actually have only one instance of the class files for you to work with. This is as good as it gets for very small projects with a harsh requirement of “no DLLs please”. Use it wisely, grasshopper.

Setting the record straight on MVP newsgroups

Lessons learned from IVBUG