Fakes不会在正常单元测试上下文中运行

Fakes不会在正常单元测试上下文中运行

本文介绍了Microsoft.Fakes不会在正常单元测试上下文中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的一个简单证明了概念假货NUnit测试:

I'm using a simple proof-of-concept Fakes nUnit test:

  [Test]
  public void TestFakes()
  {
      using (var ctx = ShimsContext.Create())
      {
          System.Fakes.ShimDateTime.NowGet = () => { return new DateTime(2000, 1, 1); };

          Assert.That(DateTime.Now.Year, Is.EqualTo(2000));
      }
  }

本测试运行在Visual Studio的测试资源管理器,但不运行:

This test runs in the Visual Studio Test Explorer, but doesn't run in:


  • NUnit的GUI

  • NUnit的控制台

  • JetBrains的测试运行器(dotCover或ReSharper的)

  • TestDriven.net测试运行

  • nUnit GUI
  • nUnit console
  • The JetBrains test runner (dotCover OR Resharper)
  • TestDriven.net test runner

在每个这些,我收到以下错误:

In each of these, I receive the following error:

Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException:无法解析从COR_PROFILER_PATH和COR_PROFILER环境变量探查路径

当我反映到该程序集,现在看来似乎在寻找的IntelliTrace,一VS Ultimate-只有拥有 - 我只安装了高级

When I reflect into that assembly, it seems like it's looking for Intellitrace, a VS Ultimate-only feature - I only have Premium installed.

如何解决这个任何建议(我们用我们的构建服务器上NUnit的亚军,所以这是一个拦截器使用正版正货)

Any suggestions on how to work around this (we use the nUnit runner on our build servers, so this is a blocker to using Fakes)

推荐答案

我不认为你将能够执行任何使用其他然后MS测试框架MS假货为基础的测试。

I don't think you will be able to execute MS Fakes based tests using anything other then MS Test framework.

我相信MS假货的工作方式导致了测试运行,如NUnit的问题。正是为什么是这样的话,我不知道,因为其他嘲讽的框架,如TypeMock工作,NUnit的等精细但有一些具体的事情到MS假货,这使得它更难(如果不是不可能的话)与以外的任何运行MS测试。这就是我的理论呢。

I believe that the way MS Fakes works causes problems for test runners such as NUnit. Precisely why this is the case, I don't know, since other mocking frameworks such as TypeMock work fine in NUnit, etc. But there is something specific to MS Fakes which make it harder (if not impossible) to run with anything other than MS Test. That's my theory anyway.

除非NUnit的,的xUnit等的作者补充支持MS假货(或者是有狡猾的解决方法),我想你一定要坚持与MS测试

Unless the authors of NUnit, xUnit, etc add support for MS Fakes (or there is a crafty workaround), I think you will have to stick with MS Test.

编辑:

它看起来像的 V2.5并与MS假货工作。我试过在测试期间它的发展,可以确认MS假的测试,而不执行使用NCrunch失败。

It looks like the latest version of NCrunch v2.5 does work with MS Fakes. I've tried the beta during it's development, and can confirm that MS Fake tests were executed without fail using NCrunch.

这篇关于Microsoft.Fakes不会在正常单元测试上下文中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 18:53