views:

262

answers:

2

I am forcing myself to learn test-driven development, and so far I'm enjoying myself. There's a few quirks that Visual Studio Unit Testing has that is driving me batty though. A bit of background information, my project folder looks like this:

  • [Root] BitFlex
  • BitFlex\Code
  • BitFlex\Debug
  • BitFlex\Documents
  • BitFlex\Release

Now of course all the source code is stored in the code folder, and on a build the project output either goes to the debug or release folders depending on the current configuration. Now for my unit testing, I have it setup so the test project is output to either:

  • BitFlex\Debug\Unit Tests\
  • BitFlex\Release\Unit Tests\

1) At this point, everything is fine and dandy. There are two problems with this, the first being that when I run a test it cannot find the assembly, as it gives me this error:

Error   AssignDefaultProgramTest BitFlex.UnitTests The test assembly 'D:\src\DCOM Productions\BitFlex\Code\TestResults\David Anderson_DCOMPRODUCTIONS 2009-07-31 23_21_00\Out\BitFlex.UnitTests.dll' cannot be loaded. Error details: Could not find file 'D:\src\DCOM Productions\BitFlex\Code\TestResults\David Anderson_DCOMPRODUCTIONS 2009-07-31 23_21_00\Out\BitFlex.UnitTests.dll'.

I cannot seem to find information on this error, or how to resolve it so I suppose that's where everyone's experise around here comes in to play.

2) My other beef is that Visual Studio generates the "Test Results" folder in my code directory, I would prefer to move that to my Unit tests folder in either output configuration. Is there a way to do this, or a better practice to setting up a well organized Unit Test using my folder hierarchy?

+1  A: 

By default MSTesting framework runs all tests in an 'isolated' location and not from the binaries directory. To fix this you can do one of these two: 1. go to the test configuration file and under deployment uncheck deploy the tests. 2. don't use path when looking for external files instead use deploy attribute or the test config to deploy the needed files along with your tests.

Dror Helper
Okay, it found my assembly by providing a deployment path. Now hopefully someone can shed some light on moving that TestResults folder..
David Anderson
A: 

For doing TDD with MSTest, turn off deployment. You shouldn't need it for "unit testing."

Also, never ever EVER have VS automatically generate tests for you. What's generated may be fine for some types of functional testing, but are usually very poor unit tests.

kyoryu