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?
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
TestContext
you can safely remove it altogether.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With