Visual Studio 2008 Unit test does not pick up code changes unless I build the entire solution
- by Orion Edwards
Here's the scenario:
Change my code:
Change my unit test for that code
With the cursor inside the unit test class/method, invoke VS2008's "Run tests in current context" command
The visual studio "Output" window indicates that the code dll and the test dll both successfully build (in that order)
The problem is however, that the unit test does not use the latest version of the dll which it has just built. Instead, it uses the previously built dll (which doesn't have the updated code in it), so the test fails.
When adding a new method, this results in a MethodNotImplementedException, and when adding a class, it results in a TypeLoadException, both because the unit test thinks the new code is there, and it isn't!. If I'm just updating an existing method, then the test just fails due to incorrect results.
I can 'work around' the problem by doing this
Change my code:
Change my unit test for that code
Invoke VS2008's 'Build Solution' command
With the cursor inside the unit test class/method, invoke VS2008's "Run tests in current context" command
The problem is that doing a full build solution (even though nothing has changed) takes upwards of 30 seconds, as I have approx 50 C# projects, and VS2008 is not smart enough to realize that only 2 of them need to be looked at. Having to wait 30 seconds just to change 1 line of code and re-run a unit test is abysmal.
Is there anything I can do to fix this? None of my code is in the GAC or anything funny like that, it's just ordinary old dll's (buiding against .NET 3.5SP1 on a win7/64bit machine)
Please help!