sha*_*ner 8 build-process microsoft-fakes visual-studio-2012 tfs2012
我有2个单元测试组件:
两者都使用Microsoft Fakes Framework(使用Stubs 和 Shims).
在本地运行单元测试工作正常(在4台不同的机器上测试,甚至在构建服务器上安装的Visual Studio上测试),但是如果我们使用构建代理构建,则某些单元测试会失败,例外情况如下:
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'.
Run Code Online (Sandbox Code Playgroud)
或垫片相同:
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'.
Run Code Online (Sandbox Code Playgroud)
有趣的是,他们偶尔失败,我试图编制一些统计数据:
# | 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
Run Code Online (Sandbox Code Playgroud)
请注意,除了上述更改之外,没有人更改源代码.
所有构建都使用详细的日志级别进行; Shim Diagnostic ="true";
只有明确需要的填充/存根包含在.fakes文件中(其他的MSBUILD使用退出代码1失败).
这对我来说似乎都很神奇,可能有人已经遇到过同样的问题,或者有人有提示.
提前致谢
我想我知道问题在哪里,TypeNotFoundException是正确的,至少没有生成相应的类型(如Reflector所示),这让我思考.更准确地说,每个程序集只生成一个生成的伪文件,位于[buildName]\Binaries-下,并且因为我的两个程序集伪造了相同的程序集(backend.dll) - 这很可能是在竞争条件下 - 一个程序集比其他人生成的最后一个垫片/存根生成; 但这并没有澄清所有问题.
无论如何,这不会出现在常规VS构建上的原因是因为程序集在它们各自的[assembly]\FakeAssemblies目录中生成,而不影响任何其他单元测试(它应该是这样的方式).
因此,我想避免这个问题的想法是将两个测试程序集使用的所有填充/存根都放入.fakes-configuration-files; 反射器显示这次真正生成了所有需要的垫片/存根,但是构建失败了
Exception Message: MSBuild error 1 has ended this build.
Run Code Online (Sandbox Code Playgroud)
任何(详细)日志中都没有更多信息.这个问题是由于没有使用.fakes文件中指定的生成的shim/stub-object引起的(当然这也是构建服务器显示的问题,否则会太无聊;-)).
因此,我提出的最终解决方案是将使用填充/存根的所有代码放入同一个程序集中,其中只有1个.fakes-file配置伪程序集.
现在它工作得很好:-),但我认为MS-Dev-Team还有一些事情要做,虽然没有用TFS2013测试过; 无论如何都要提交一个bug(因为我已经发现了2个)
希望这可以帮助有同样问题的人.
| 归档时间: |
|
| 查看次数: |
2630 次 |
| 最近记录: |