【发布时间】:2017-08-04 11:06:38
【问题描述】:
我正在使用 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: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 在 Telerik.JustMock.Core.MocksRepository.InterceptStatics(类型类型,IEnumerable1 mixins, IEnumerable1 补充行为,IEnumerable1 fallbackBehaviors, Boolean mockStaticConstructor)
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.MockBuilder.InterceptStatics(MocksRepository repository, Type type, Nullable1 行为,布尔 mockStaticConstructor)
2017-08-04T08:24:12.0462606Z 在 Telerik.JustMock.Core.MocksRepository.ConvertExpressionToCallPattern (Expression expr, CallPattern callPattern)
2017-08-04T08:24:12.0462606Z 在 Telerik.JustMock.Core.MocksRepository.Arrange[TMethodMock](表达式 expr,Func1 methodMockFactory)
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Mock.<>c__DisplayClass1_01.b__0()
2017-08-04T08:24:12.0462606Z 在 Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func1 guardedAction)
2017-08-04T08:24:12.0462606Z at Telerik.JustMock.Mock.Arrange[TResult](Expression1 表达式)
2017-08-04T08:24:12.0462606Z 在
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
如果有 Telrik JustMock 与 VSTS asp.net 构建模板集成的知识,任何人都可以分享。
我在这里找到了使用基于 XAML 的构建模板运行 Telrik JustMock 的链接: http://docs.telerik.com/help/justmock/integration-tfs-2013.html
我也在使用 Asp.Net 构建模板的测试运行任务。
【问题讨论】:
标签: asp.net unit-testing telerik azure-pipelines justmock