Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Testing in VS2010

My company recently upgraded our project to VS2010 from VS2008. One area of concern is our unit tests. In VS 2008 most unit tests have this piece of code public TestContext TestContext { get; set; } in VS2008 there was no issues with this, but with VS2010 I am now receiving errors like this:

Unable to set TestContext property for the class VisitorTestAdapterTest. Error: System.ArgumentException: Object of type 'Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapterContext' cannot be converted to type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestContext'

If i simply comment this out the test work fine, But was looking as to the reason that this is being caused. Does anyone know what changed with the unit tests framework?

like image 514
Jamie Babineau Avatar asked Oct 06 '22 05:10

Jamie Babineau


1 Answers

Ensure that the correct TestContext-type is referenced. For VS2010 this is the mentioned Microsoft.VisualStudio.TestTools.UnitTesting.TestContext. Thus:

  • ensure that the unit tests have the correct using-statements:

    using Microsoft.VisualStudio.TestTools.UnitTesting;
    
  • ensure that the correct library is referenced by your test-project

  • if your tests do not make use of the TestContext you can safely remove it altogether.
like image 145
Spontifixus Avatar answered Oct 10 '22 03:10

Spontifixus