NCover with MSTest: TestContext not set

NCover with MSTest: TestContext not set

Hi I am using NCover v3.1.2 against a project created in Visual Studio and therefore using the MSTest framework. All my tests run successfully when run from Visual Studio or from the command line using MSTest.exe. I am now trying to run the same tests from thr NCover explorer, as I want to get code coverage metrics on my tests. But the tests do not run successfully from NCover. The problem is that my tests make use of the TestContext class. Specifically, they rely on the fact that the following TestContext getter and setter gets called during test initialisation: private TestContext context;

 public TestContext TestContext
 {
   get { return context; }
   set {
        Console.WriteLine("BaseTest: Setting context to "+value); 
        context = value; 
       }
 }

The problem is that the setter is not called, so context is null and consequently the tests fail. So my question is why are the same tests running differently when NCover is used? Is there some kind of workaround I can use to get NCover to execute my tests? Is NCover supposed to support the initialisation of TestContext? thanks Michael


RE: NCover with MSTest: TestContext not set

michael, I've elevated this post to a support request. you should get an email soon.


RE: NCover with MSTest: TestContext not set

Was this issue ever resolved? I'm having the same problem.


RE: NCover with MSTest: TestContext not set

it turned out to be a setup error. What's your setup look like?


RE: NCover with MSTest: TestContext not set

Hi,

Do you find a solution ?

Thanks,


RE: NCover with MSTest: TestContext not set

Hi juignet,

As an earlier reply states, this turned out to be a setup issue.

I checked the support ticket and the original poster said he resolved the problem by following the MSTest instructions here:

http://docs.ncover.com/how-to/running-ncover-with-your-unit-testing-framework/mstest/

Please let us know if this helps.

Thanks!

NCover Support