【问题标题】:Microsoft Fakes generates UnitTestIsolationExceptionMicrosoft Fakes 生成 UnitTestIsolationException
【发布时间】:2014-01-08 07:45:13
【问题描述】:

我编写了非常简单的单元测试项目来查看 Microsoft Fakes 的能力。我已经在系统程序集上执行了菜单命令“添加假货程序集”。

public static class Y2KChecker
{
    public static void Check()
    {
        if (DateTime.Now == new DateTime(2000, 1, 1))
            throw new ApplicationException("y2kbug!");
    }
}

[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestYear()
    {
        using (ShimsContext.Create())
        {
            ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);
            Y2KChecker.Check();
        }
    }
}

但是使用 (ShimContext.Create()) 我总是得到 UnitTestIsolationException:

SetDetourProvider 在分析器库“C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\11.0.0\Microsoft.IntelliTrace.Profiler.11.0.0.dll”中返回意外错误。

我的 Visual Studio 2012 Update 2 也安装了 Resharper。如何解决这个异常?

【问题讨论】:

  • 你的例子对我来说没问题。能否请您发布有关 Microsoft.IntelliTrace.Profiler.11.0.0.dll 的版本和版权信息?
  • 您是否尝试过关闭 Resharper 是否有效?

标签: c# visual-studio-2012 microsoft-fakes


【解决方案1】:

从 2012 年 11 月起,您不能同时运行 Resharper 和 MS Fakes。大约一年前提出了使其兼容的请求。

http://devnet.jetbrains.com/message/5470396?tstart=0

【讨论】:

    【解决方案2】:

    到现在(2014 年 3 月),您只能在 Visual Studio 测试运行程序 (vstest.console.exe) 中运行使用 MS Fakes 的测试。当然,您可以继续使用 ReSharper,但它的测试运行器无法运行您的测试。

    【讨论】:

      【解决方案3】:

      我在使用 VS2012 + ReSharper 时遇到了同样的问题,我在没有 ReSharper 的情况下切换到 VS2013 并且效果很好。

      我回到 VS2012 并尝试 suspend ReSharper 但这并没有解决问题。

      【讨论】:

        【解决方案4】:

        就我而言,问题仅发生在 TeamCity。

        我通过从 MSTest 切换到 VSTest 解决了。

        【讨论】:

          【解决方案5】:

          截至 2017 年 10 月,我能够通过 Resharper 运行测试,但在收集代码覆盖率时无法运行

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2012-09-03
            • 2023-04-03
            • 2015-09-21
            • 1970-01-01
            • 2018-11-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多