在 tfs 中使用 Moq 使 xUnit 测试失败
Fail xUnit tests with Moq in tfs
我有三个使用 Xunit 2.3.0 编写的测试,我使用 Castle.Core 4.2.0 使用的 Moq 4.7.137 模拟了一些服务。
我的测试在我的本地工作区中正常工作,但在 Team Foundation Server 2015 中它们失败并出现以下错误:
2017-10-10T08:20:44.7293310Z Information: [xUnit.net 00:00:22.8448542] System.AggregateException : One or more errors occurred.
2017-10-10T08:20:44.7293310Z Information: [xUnit.net 00:00:22.8457824] ---- System.MissingMethodException : Method not found: 'Boolean Castle.DynamicProxy.ProxyUtil.IsAccessible(System.Reflection.MethodBase, System.String ByRef)'.
2017-10-10T08:20:44.7293310Z Information: [xUnit.net 00:00:22.8466110] ---- The following constructor parameters did not have matching fixture data: LoanFixture fixture
2017-10-10T08:20:44.7449508Z Information: [xUnit.net 00:00:22.8598342] Stack Trace:
2017-10-10T08:20:44.7449508Z Information: [xUnit.net 00:00:22.8607783]
2017-10-10T08:20:44.7449508Z Information: [xUnit.net 00:00:22.8615987] ----- Inner Stack Trace #1 (System.MissingMethodException) -----
2017-10-10T08:20:44.7449508Z Information: [xUnit.net 00:00:22.8624251] at Moq.Proxy.CastleProxyFactory.IsMethodVisible(MethodInfo method, String& messageIfNotVisible)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8632101] C:\projects\moq4\Source\Mock.cs(811,0): at Moq.Mock.ThrowIfSetupMethodNotVisibleToProxyFactory(MethodInfo method)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8640470] C:\projects\moq4\Source\Mock.cs(439,0): at Moq.Mock.<>c__DisplayClass62_0`1.<Setup>b__0()
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8648863] C:\projects\moq4\Source\PexProtector.cs(61,0): at Moq.PexProtector.Invoke[T](Func`1 function)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8656833] C:\projects\moq4\Source\Mock.cs(432,0): at Moq.Mock.Setup[T](Mock`1 mock, Expression`1 expression, Condition condition)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8664444] C:\projects\moq4\Source\Mock.Generic.cs(263,0): at Moq.Mock`1.Setup(Expression`1 expression)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8672662] s\Banking\Banking.LoanManagement.Domain.Tests\Core\LoanFixture.cs(98,0): at Banking.LoanManagement.Domain.Tests.Core.LoanFixture.Initialize()
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8680978] s\Banking\Banking.LoanManagement.Domain.Tests\Core\LoanFixture.cs(36,0): at Banking.LoanManagement.Domain.Tests.Core.LoanFixture..ctor()
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8688788] ----- Inner Stack Trace #2 (Xunit.Sdk.TestClassException) -----
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8696267]
我已经签入了所有相关包。
我还在 tfs 测试任务上设置了测试运行器。但我无法解决这个问题
这是一个老问题,我忘记回答了。在这种情况下,问题与以前版本中的specflow bug有关,然后已修复。
我有三个使用 Xunit 2.3.0 编写的测试,我使用 Castle.Core 4.2.0 使用的 Moq 4.7.137 模拟了一些服务。 我的测试在我的本地工作区中正常工作,但在 Team Foundation Server 2015 中它们失败并出现以下错误:
2017-10-10T08:20:44.7293310Z Information: [xUnit.net 00:00:22.8448542] System.AggregateException : One or more errors occurred.
2017-10-10T08:20:44.7293310Z Information: [xUnit.net 00:00:22.8457824] ---- System.MissingMethodException : Method not found: 'Boolean Castle.DynamicProxy.ProxyUtil.IsAccessible(System.Reflection.MethodBase, System.String ByRef)'.
2017-10-10T08:20:44.7293310Z Information: [xUnit.net 00:00:22.8466110] ---- The following constructor parameters did not have matching fixture data: LoanFixture fixture
2017-10-10T08:20:44.7449508Z Information: [xUnit.net 00:00:22.8598342] Stack Trace:
2017-10-10T08:20:44.7449508Z Information: [xUnit.net 00:00:22.8607783]
2017-10-10T08:20:44.7449508Z Information: [xUnit.net 00:00:22.8615987] ----- Inner Stack Trace #1 (System.MissingMethodException) -----
2017-10-10T08:20:44.7449508Z Information: [xUnit.net 00:00:22.8624251] at Moq.Proxy.CastleProxyFactory.IsMethodVisible(MethodInfo method, String& messageIfNotVisible)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8632101] C:\projects\moq4\Source\Mock.cs(811,0): at Moq.Mock.ThrowIfSetupMethodNotVisibleToProxyFactory(MethodInfo method)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8640470] C:\projects\moq4\Source\Mock.cs(439,0): at Moq.Mock.<>c__DisplayClass62_0`1.<Setup>b__0()
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8648863] C:\projects\moq4\Source\PexProtector.cs(61,0): at Moq.PexProtector.Invoke[T](Func`1 function)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8656833] C:\projects\moq4\Source\Mock.cs(432,0): at Moq.Mock.Setup[T](Mock`1 mock, Expression`1 expression, Condition condition)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8664444] C:\projects\moq4\Source\Mock.Generic.cs(263,0): at Moq.Mock`1.Setup(Expression`1 expression)
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8672662] s\Banking\Banking.LoanManagement.Domain.Tests\Core\LoanFixture.cs(98,0): at Banking.LoanManagement.Domain.Tests.Core.LoanFixture.Initialize()
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8680978] s\Banking\Banking.LoanManagement.Domain.Tests\Core\LoanFixture.cs(36,0): at Banking.LoanManagement.Domain.Tests.Core.LoanFixture..ctor()
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8688788] ----- Inner Stack Trace #2 (Xunit.Sdk.TestClassException) -----
2017-10-10T08:20:44.7605671Z Information: [xUnit.net 00:00:22.8696267]
我已经签入了所有相关包。 我还在 tfs 测试任务上设置了测试运行器。但我无法解决这个问题
这是一个老问题,我忘记回答了。在这种情况下,问题与以前版本中的specflow bug有关,然后已修复。