Search code examples
tfsmoqxunitcastle

Fail xUnit tests with Moq in tfs


I have three test that wrote using Xunit 2.3.0 and I mocked some services using Moq 4.7.137 that is used Castle.Core 4.2.0 . My tests work correctly in my local workspace but in Team Foundation Server 2015 they fail with following error :

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]    

I have checkedin all releated packages . I also set test runner on tfs test task . but I can not solve this


Solution

  • This is an old question and I forgot to answer that. In this case, the problem was related to specflow bug in the previous version and then it is fixed.