我在单元测试中使用Telrik JustMock模拟。在本地它工作得很好,但当我尝试将它与基于Asp.net构建模板的VSTS构建集成时,它以错误告终。错误的堆栈跟踪如下:
Failed ValidateNodeRegisteredReturnsTrue
2017-08-04T08:24:12.0452600Z Error Message:
2017-08-04T08:24:12.0452600Z Assert.IsFalse failed.
2017-08-04T08:24:12.0452600Z Stack Trace:
2017-08-04T08:24:12.0452600Z at
xxx.UnitTests.TemplateManagerUnitTests.ValidateNodeRegisteredReturnsTrue() in d:\a\1\s\Dev\TSys Project\8. Unit Tests\XXX.WebMVC.Tests\UnitTests\ManagerUnitTests.cs:line 36
2017-08-04T08:24:12.0462606Z
2017-08-04T08:24:12.0462606Z Failed ValidateExtractPackageOnLocalServer
2017-08-04T08:24:12.0462606Z Error Message:
2017-08-04T08:24:12.0462606Z Test method
xxx.UnitTests.ManagerUnitTests.ValidateExtractPackageOnLocalServer threw exception:
2017-08-04T08:24:12.0462606Z Telerik.JustMock.Core.ElevatedMockingException: Cannot mock 'TemplateCreationService.TemplateUtility'. The profiler must be enabled to mock, arrange or execute the specified target.
2017-08-04T08:24:12.0462606Z Detected active third-party profilers:
2017-08-04T08:24:12.0462606Z * Visual Studio 2015 Code Coverage/IntelliTrace (from process environment)
2017-08-04T08:24:12.0462606Z Disable the profilers or link them from the JustMock configuration utility. Restart the test runner and, if necessary, Visual Studio after linking.
2017-08-04T08:24:12.0462606Z Stack Trace:
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Core.ProfilerInterceptor.ThrowElevatedMockingException(MemberInfo member)
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Core.MocksRepository.InterceptStatics(Type type, IEnumerable`1 mixins, IEnumerable`1 supplementaryBehaviors, IEnumerable`1 fallbackBehaviors, Boolean mockStaticConstructor)
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.MockBuilder.InterceptStatics(MocksRepository repository, Type type, Nullable`1 behavior, Boolean mockStaticConstructor)
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Mock.<>c__DisplayClass34_0.<SetupStatic>b__0()
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal(Action guardedAction)
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Mock.SetupStatic(Type staticType)
2017-08-04T08:24:12.0462606Z at xxx.UnitTests.ManagerUnitTests.ValidateExtractPackageOnLocalServer() in d:\a\1\s\Dev\TSys Project\8. Unit Tests\xxx.WebMVC.Tests\ServiceUnitTests\ManagerUnitTests.cs:line 44
2017-08-04T08:24:12.0462606Z
2017-08-04T08:24:12.0462606Z Error Message:
2017-08-04T08:24:12.0462606Z Test method
xxx.UnitTests.ManagerUnitTests.ShouldAssertCustomValueForDateTimeNow threw exception:
2017-08-04T08:24:12.0462606Z Telerik.JustMock.Core.ElevatedMockingException: Cannot mock 'System.DateTime'. The profiler must be enabled to mock, arrange or execute the specified target.
2017-08-04T08:24:12.0462606Z Detected active third-party profilers:
2017-08-04T08:24:12.0462606Z * Visual Studio 2015 Code Coverage/IntelliTrace (from process environment)
2017-08-04T08:24:12.0462606Z Disable the profilers or link them from the JustMock configuration utility. Restart the test runner and, if necessary, Visual Studio after linking.
2017-08-04T08:24:12.0462606Z Stack Trace:
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Core.ProfilerInterceptor.ThrowElevatedMockingException(MemberInfo成员) 2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Core.MocksRepository.InterceptStatics(Type type,Boolean 1 mixins, IEnumerable1 supplementaryBehaviors,IEnumerable1 fallbackBehaviors, Boolean mockStaticConstructor) 2017-08-04T08:24:12.0462606Z at Telerik.JustMock.MockBuilder.InterceptStatics(MocksRepository repository, Type type, Nullable1 behavior,Boolean mockStaticConstructor) 2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Core.MocksRepository.ConvertExpressionToCallPattern(Expression expr,CallPattern callPattern) 2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Core.MocksRepository.ArrangeTMethodMock 2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Mock.<>c__DisplayClass1_01.b\_\_0() 2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func1 guardedAction) 2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Mock.ArrangeTResult 2017-08-04T08:24:12.0462606Z at
xxx.UnitTests.ManagerUnitTests.ShouldAssertCustomValueForDateTimeNow() in d:\a\1\s\Dev\TSys Project\8. Unit Tests\xxx.WebMVC.Tests\ServiceUnitTests\ManagerUnitTests.cs:line 57
2017-08-04T08:24:12.0472600Z Failed ShouldAssertCustomValueForDateTimeNow任何人都可以分享如果有与VSTS asp.net构建模板集成Telrik JustMock的知识。
我在这里找到了使用基于XAML的构建模板运行Telrik JustMock的链接:http://docs.telerik.com/help/justmock/integration-tfs-2013.html
我还使用了Asp.Net构建模板的测试运行任务。
发布于 2017-08-07 13:28:10
基于对"Profiler must be enabled" exception in JustMock文章的处理,免费版本不允许使用分析器。另外,一个NuGet package for JustMock pro的线程。
您需要在安装了JustMock的服务器上使用setup a on-premise build agent,并且此私有生成代理在您的帐户下运行。
https://stackoverflow.com/questions/45505242
复制相似问题