Posts Tagged ‘configuration’

Visual studio test project fails compiling due to clashing test name

June 25th, 2011

In Visual studio 2010 I have a solution with some projects and a unit test project.  Besides the usual configurations Debug and Release I also have Debug_Test.  One sunny day when compiling the project …

… I  got a dialogue with

Duplicate Detected Loading Add from test.dll

In attempting to load Add form test\bin\debug\test.dll, it was determined that a test with the same id name Add in test\bin\debug_test\test.dll already exists in the catalog.

If you retry, Add from test\bin\debug\test.dll will have its id replaced with a new one.

when I tried to compile my solution with Debug_Test active. (or if it was the other way around)

When I pressed Retry I got

Error loading C:\Test\bin\Debug\Test.dll: The test ‘Add’ from ‘c:\test\bin\debug\test.dll’ that is loading has the same TestId {2704e894-0db5-60e4-53Ed-61c7e6951c9f} as the test ‘Add’ already loaded from ‘c:\test\bin\debug_test\test.dll’.

in the output console.

What was happening?
Check out the emphasis (I created). There are two compile configurations that clash.

I want Debug to compile the whole solution with the debug flag set (to know that everything compiles as it should).  Then I have a Debug_Test configuration that only compiles the parts of the solution that are needed for my automatic tests.  In the inner machinery of Visual studio 2010 there is something that tracks test methods and it looks like it regards Add from Debug configuration and Add from Debug_Test configuration as two different tests, albeit with the same name.
In reality they are the same unit test method code.

The whys and the hows are beyond my scope but I found a work around.
Go to the other configuration (i.e. Debug) and clean the output. Then go back to the one you want to work with (i.e. Debug_Test) and continue as usual.

One could possibly have created Debug_Test without checking Create new project configurations to avoid this too.  If anyone knows, please comment.