加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – TFS伪造构建单元测试失败

发布时间:2020-12-15 07:40:03 所属栏目:百科 来源:网络整理
导读:我们有一个VS2013 .net 5.0解决方案(VS2013 Premium),所有单元测试都在本地传递正常,但是在TFS Build中使用此类似或类似的异常运行VS测试加载器时未通过多次测试:System.TypeLoadException:无法加载类型’System.Diagnostics .Fakes.ShimEventLog’来自程
我们有一个VS2013 .net 5.0解决方案(VS2013 Premium),所有单元测试都在本地传递正常,但是在TFS Build中使用此类似或类似的异常运行VS测试加载器时未通过多次测试:System.TypeLoadException:无法加载类型’System.Diagnostics .Fakes.ShimEventLog’来自程序集’System.4.0.0.0.Fakes,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 0ae41878053f6703′.
这是一个失败测试的例子:
[TestMethod]
    public void WriteToEventLogTest_HappyPath()
    {
        EventLogEntryType eTypeInfo = EventLogEntryType.Information;
        bool sourceExistCalled = false;
        bool writeEntrycalled = false;

        using (ShimsContext.Create())
        {
            ShimEventLog.SourceExistsString = s =>
            {
                sourceExistCalled = true;
                return true;
            };

            ShimEventLog.AllInstances.WriteEntryStringEventLogEntryType = (@this,str,et) =>
            {
                writeEntrycalled = true;
            };

            Logging.WriteToEventLog(IpAddress,eTypeInfo);
            Assert.IsTrue(sourceExistCalled,"SourceExist() not called");
            Assert.IsTrue(writeEntrycalled,"WriteEntry() not called");
        }
    }`

我们使用在Windows Server 2012 R2上运行的TFS 2013更新5.有什么可能导致这个问题吗?我们是否应该将TFS更新到最新的更新5?

解决方法

通过在解决方案级别上的测试项目之间共享伪造配置文件来解决问题

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读