Reputation: 123662
Here's the scenario:
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
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!
Upvotes: 1
Views: 1117
Reputation: 123662
After a bit more digging, I fixed the problem:
I then diffed the .csproj to see what had changed, and it was as follows
Old and broken
<ProjectReference Include="..\Base\Base.csproj">
<Project>{1C61F557-24C5-4B4A-90A8-08D0DCEE15A1}</Project>
<Name>Base</Name>
<Private>False</Private>
</ProjectReference>
New and good
<ProjectReference Include="..\Base\Base.csproj">
<Project>{1C61F557-24C5-4B4A-90A8-08D0DCEE15A1}</Project>
<Name>Base</Name>
</ProjectReference>
The <Private>False</Private>
bit apparently means "Copy Local" so this explains it. Note to self: Remember to set Copy Local to true for unit tests!
Upvotes: 1