【发布时间】:2017-08-31 13:15:06
【问题描述】:
我们有一个 VS2013 .net 5.0 解决方案(VS2013 高级版),所有单元测试在本地都通过了,但在 TFS 构建的 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");
}
}`
我们使用在 Windows Server 2012 R2 上运行的 TFS 2013 更新 5。有什么可能导致这个问题吗?我们是否应该将 TFS 更新到目前的最新版本,即 Update 5?
【问题讨论】:
-
程序集是否在 TFS 机器上,在本地工作区目录(我不熟悉 TFS)或 GAC 中?
-
感谢您的回复。程序集在 Build Agent 机器上,但不转到 GAC
-
尝试启用融合日志记录。不用说,但是您是否仔细检查了 DLL 是否位于预期/正确的位置,并且版本、文化和公钥标记都完全匹配?
-
是的,程序集位于指定位置,版本匹配,但 TFS 在未通过测试时构建失败,因此没有输出。
-
你创建了什么样的单元测试。automapper 测试或者别的什么