Visual studio test project fails compiling due to clashing test name

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.

Tags: , , ,

3 Responses to “Visual studio test project fails compiling due to clashing test name”

  1. StalePhish says:

    This is the only result I could find on Google for this particular issue! I was having a similar problem, but mine was only appearing with one particular test when I was doing a batch build of Debug and Release at the same time, and it was complaining about bin\Release\Foo.dll has the same TestId {…} as the test “Foo’ already loaded from bin\Debug\Foo.dll. I clean manually deleting the bin folders and trying again just made it go away.

  2. Rami Abughazaleh says:

    Thank you.

    Deleting the bin and obj directories worked for me!

    This happened when I changed my project’s properties to target x86 instead of “Any CPU” for example.

  3. Emil Cristen says:

    I just closed VS and re-opened the solution again. Run a clean Solution and then the rebuild. This solved the problem for me.

Leave a Reply