0

I am using unit test project along with MS Fakes mocking framework within

Visual Studio Premium 2013 Update 4

. It works fine when I run my tests within visual studio, but when I try to debug unit test cases it fails with below error:

Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables.

Following methods I have tried:

  1. Specific Version to false [Not worked]
  2. Removed all fakes, clean, build and readded [Not worked]
  3. Added System and mscorlib fakes [Not worked]

Edit:

[TestMethod]
public void LoginResponseTest()
{
    using (ShimsContext.Create())//Getting error here in case of debug test
    {

      var stub = new StubISimpleHttpService();
      stub.SendPostRequestStringParameterCollection = GetLoginResponse;
      MyAPIConnector connector = new MyAPIConnector();
      uint response = connector.login("test_username", "test_password");

      Assert.IsTrue(response == 0);                
    }    
}

Any solutions?

Sandy
  • 6,285
  • 15
  • 65
  • 93
  • I doubt that anybody is able to reproduce this error with the knowledge from this post. Please provide an [MCVE](http://stackoverflow.com/help/mcve). – TobiMcNamobi Oct 06 '15 at 09:57
  • How are you debugging the tests? Do you use any third-party tool such as Jetbrains Resharper test runner? I've seen that error before when I tired to debug unit tests, that contain MS Fakes, using Resharper. – Jason Evans Oct 07 '15 at 08:54
  • No, Default unit testing provided by VS3013 – Sandy Oct 07 '15 at 08:56
  • [For reference](http://stackoverflow.com/questions/19385037/microsoft-fakes-wont-run-in-normal-unit-test-contexts) – Jason Evans Oct 07 '15 at 08:57
  • Out of curiosity, trying running Visual Studio as an administrator, and then attempt to debug the tests? Does that make any difference? – Jason Evans Oct 07 '15 at 09:00
  • I tried that but no luck. It is working fine while adding StubGeneration in fakes settings – Sandy Oct 07 '15 at 09:03

1 Answers1

-1

I have added Interfaces which i need stub into settings of fakes. For example:

<StubGeneration>
  <Clear/>
  <Add Interfaces="true" FullName="ISimpleHttpService"/>
</StubGeneration>
<ShimGeneration>
  <Clear/>
  <Add FullName="HttpResponse"/>
</ShimGeneration>

Explanation: We need to add only those fakes dll which are being used by unit test fakes. And We need to add StubGeneration tags to xml file. These tags depends on the classes which are using by unit test cases.

Sandy
  • 6,285
  • 15
  • 65
  • 93
  • Please explain how you discover that, I'm facing the same issue here and there's a lot of fake types to check. – Marcus Vinicius Jul 29 '16 at 13:51
  • @MarcusVinicius: I have added explanation to my answer. Please look into it. If it is not resolving your problem then please add error details. – Sandy Aug 05 '16 at 06:23