Environment
- Visual Studio 2012 Premium Update 3
- Team Foundation Server 2012 Update 3
- edit: .NET Framework 4
- DefaultTemplate (DefaultTemplate.11.1.xaml)
- Visual Studio Test Runner
- Target Platform: X86
- Visual Studio Test Runner
Problem
I have 2 Unit-Test-Assemblies:
- ExtensionTests
- UserTests
both make use of the Microsoft Fakes Framework (using Stubs and Shims).
Running the unit tests locally works fine (tested on 4 different machines, even on the Visual Studio installed on the build server), however if we build using a build agent, some unit test fails with the exception, e.g.:
Unable to create instance of class UserTests.ClientUserTest. Error: System.TypeLoadException: Could not load type 'WorldDirect.CCM.Shared.Backend.SmartClassic.Fakes.StubClient' from assembly 'WorldDirect.Smart.Backend.Fakes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
or the same for a shim:
Test method ExtensionTests.ExtensionTests.UpdateExtensionValidate_NoGrnp_ChecksIpPbxDependencies threw exception: System.TypeLoadExceptio: Could not load type 'WorldDirect.CCM.Shared.Backend.SmartClassic.Fakes.ShimIpPbxRemoteDestination' from assembly 'WorldDirect.Smart.Backend.Fakes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
The interesting thing is, they fail sporadically, I've tried to make up a little statistics:
# | Outcome | Comment
19 | 64/64 passed | only 'UserTests'-UnitTests run, 'ExtensionTests' inactive
20 | 37/64 passed | same source code as #19
21 | 64/64 passed | same source code as #19
22 | 64/66 passed | all 'UserTests' run as well as 2 'ExtensionTests', others still inactive; the 2 ExtensionTests failed with ShimIpPbxRemoteDestination-TypeLoadException
23 | 38/65 passed | same source code as #22, notice NOTHING has changed, however 1 unit test was not even run in 'ExtensionTests'; however the second succeeds; all unit tests in 'UserTests' using MS Fakes fail with a StubClient-TypeLoadException
24 | 38/65 passed | same source code as #22
new day - no more luck :-(
1 | 37/64 passed | uncommented the 2 'ExtensionTests', so same code as #19
2 | 37/64 passed | so same code as #1
3 | 64/64 passed | so same code as #1; suddenly they all work again
Notice that beside the mentioned changes nobody has changed the source code.
All build were made using a detailed log-level ;
Shim Diagnostic="true";
only explicitly needed shims/stubs are included in .fakes-file (otherwhise MSBUILD was failing using exit-code 1).
It all seems quite magic to me, possibly somebody has already experienced the same problems or somebody has a hint.
Thanks in advance