Rob*_*ing 6 teamcity nunit moq autofixture teamcity-7.0
我以前对我的解决方案的所有单元测试都包含在一个库中,并且最近被拆分了.当位于单个程序集中时,所有测试都在本地和TeamCity上传递,但是在分离时会出现版本冲突.
配置:
我有几个单元测试程序集,它们都引用了一个基本测试库.所有测试程序集都使用上面列出的NuGet包.
在开发机器上运行测试(VS 2015)时,所有测试都成功通过.
运行团队城市构建时,会引发以下错误:
System.IO.FileLoadException:无法加载文件或程序集'Moq,Version = 4.1.1308.2120,Culture = neutral,PublicKeyToken = 69f491c39445e920'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)在Ploeh.AutoFixture.AutoMoq.MockPostprocessor.Create(对象请求,ISpecimenContext上下文)
在我的解决方案的任何地方都没有提到Moq 4.1.1308.2120,所以我知道它必须是AutoFixture的参考.
将AutoFixture更新为3.31.3没有任何区别.
我在所有测试程序集的app.config文件中都有以下Binding Redirect:
<dependentAssembly>
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1402.2112" newVersion="4.2.1402.2112" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
我无法将我的Moq版本降级到4.1.1308.2120,因为我在测试中使用了4.2的功能.
在我看来,Team City忽略了重定向.我不知道为什么,并且尝试了这些程序集的每个版本组合,我无法让Team City成功运行测试.
我们也遇到了这个问题。我们在构建服务器上运行程序集 Fusion Logs ,并在错误日志中看到了这一点:
Calling assembly : Ploeh.AutoFixture.AutoMoq, Version=3.50.2.0, Culture=neutral, PublicKeyToken=b24654c590009d4f.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Moq, Version=4.1.1308.2120, Culture=neutral, PublicKeyToken=69f491c39445e920
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///D:/builds/13/s/AssessmentMigratorService.IntegrationPostbuild/bin/Debug/Moq.DLL.
LOG: Assembly download was successful. Attempting setup of file: D:\builds\13\s\AssessmentMigratorService.IntegrationPostbuild\bin\Debug\Moq.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Moq, Version=4.5.28.0, Culture=neutral, PublicKeyToken=69f491c39445e920
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated
Run Code Online (Sandbox Code Playgroud)
所以如果你看到这一部分
找不到应用程序配置文件。
我认为正在发生的情况是,构建服务器上的单元测试运行器主机应用程序看不到应用程序配置文件,因此程序集绑定重定向无法应用,因为它们位于 app.config 中。
因此,如果您需要使用这些程序集,我看到 3 种可能的解决方案/解决方法:
归档时间: |
|
查看次数: |
1077 次 |
最近记录: |