0

我正在使用 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 

测试\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(类型类型,IEnumerable 1 mixins, IEnumerable1 补充行为,IEnumerable 1 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](Expression expr,Func 1 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](Func 1 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 构建模板的测试运行任务。

4

1 回答 1

0

根据JustMock文章处理“Profiler must be enabled”异常,免费版不允许使用profiler。此外,JustMock pro 的 NuGet 包线程。

您需要在安装了JustMock 的服务器上设置本地构建代理,并且此私有构建代理在您的帐户下运行。

于 2017-08-07T05:28:10.447 回答