For Programmers: Free Programming Magazines  


Home > Archive > Extreme Programming > December 2005 > Separating production code and tests









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Separating production code and tests
Ryan

2005-11-29, 3:56 am

Hi all,

I've written a bunch of tests for my libraries (.Net DLL) and the tests
and libs to be tested are in separate assemblies, which is what I want
so I don't 'infect' the code I'm going to ship.

When testing against an .exe for a service or desktop app I am unable
to make this separation as understandably, the .exe cannot be loaded
into my testing project in Visual Studio as a reference, therefore I
can't write tests to refer to the .exe from another assembly.

For now, I've written these tests inside the project I'm testing, but
that means my test code is all scattered (I have lots of .exes). Even
if most of the code is removed from the .exes and put into libraries,
there will always be something in the UI or service harness that needs
testing.

How have others here managed this issues or am I doing something weird?
Advice gratefully received.

Thanks

Ryan

spalding

2005-12-17, 9:14 pm

Hi

I usually populate my project with my tests but I store my tests within another namespace. So for example if I have a class like so;

MyProject.Localization.Language

I would have my unit tests in a class called;

MyProject.Localization.UnitTests.LanguageTest

I would compile the tests in during testing and debugging then when it comes time to deploy the production app, I would recompile without the unittests. I find the easiest way to do this is via an NAnt script.

I build 2 targets in the NAnt script, one for local debug builds and another for release builds. The release build's list of files to compile excludes any path with the directory name UnitTests in it.

Hope this helps.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com