TFS伪造构建单元测试失败

Vic*_*tor 7 c# tfsbuild tfs2013

我们有一个VS2013 .net 5.0解决方案(VS2013 Premium),所有单元测试在本地都很好,但是在TFS Build中使用此类似或类似的异常运行VS测试加载器时无法进行多次测试:System.TypeLoadException: Could not load type 'System.Diagnostics.Fakes.ShimEventLog' from assembly '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");
        }
    }`
Run Code Online (Sandbox Code Playgroud)

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

Vic*_*tor 3

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