【问题标题】:Telrik JustMock integration with VSTS build hosted agentTelerik JustMock 与 VSTS 构建托管代理的集成
【发布时间】: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


    【解决方案1】:

    基于处理"Profiler must be enabled" exception in JustMock 文章,免费版不允许使用profiler。还有一个NuGet package for JustMock pro的帖子。

    您需要在安装了 JustMock 并且此私有构建代理在您的帐户下运行的服务器上setup a on-premise build agent

    【讨论】:

    • 感谢您的回复,这一事实众所周知。 Telrik 的人告诉我,他们的一些客户能够以某种方式使用托管构建代理运行配置文件,我们应该尝试一下。所以我们正在为此努力。
    • @Riky 但是基于Hosted agents 文章,没有 JustMock。
    • 据您所知,并不总是要求您只能使用托管代理提供的工具来做某事。您可以以提升的方式将它们作为依赖项传递。例如,nunit 不可用,但您可以将 NUint 的引用作为测试组装任务中的测试依赖项传递。希望这会有所帮助。
    • @Riky 问题是无法在托管代理上启用 Profiler,因为您无法在托管代理上安装任何软件。即使您提供了所需的依赖项和文件,您也没有管理员权限来为探查器注册 DLL。
    • @Eddie-MSFT,虽然我们不需要在托管代理上安装分析器,但它可以在提升模式下工作。但不知何故,它需要设置一个机器级别的环境变量,而我们无权设置它,所以是的,托管代理存在问题。但这是 JustMock 分析器的奇怪行为。理想情况下,我可以设置进程级别的环境变量,JustMock 应该使用这些变量工作。 Telrik 团队应该为此做好准备。
    猜你喜欢
    • 2016-10-24
    • 2018-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-07
    相关资源
    最近更新 更多