Since recently some of my MS Test unit tests have stopped working. I haven't changed anything in the tests themselves. The error I am getting is the following:
Test Failed - [file name]
Message: Method not found: 'System.String Microsoft.VisualStudio.TestTools.UnitTesting.TestResult.get_TestContextMessages()'.
Under 'References', in my unit test Project (in Visual Studio), I have the following:
Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface
Microsoft.VisualStudio.TestPlatform.TestFramework
Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions
Moq
Ploeh.AutoFixture
Ploeh.AutoFixture.AutoMoq
Anybody know what the problem is here?
So the problem essentially is what I described in the last comment, i.e. if you create a new Unit Test project in Visual Studio 2015, it comes with Microsoft.VisualStudio.QualityTools.UnitTestFramework already installed. If you then install MSTest.TestFramework from NuGet, which is going to be MSTest version 2 (this is important to note), this is going to create Ambiguous Reference issue for test attributes such as TestClass and TestInitialize, i.e. the Unit Test project doesn't compile.
To resolve the issue above, the Microsoft.VisualStudio.QualityTools.UnitTestFramework reference can be removed from the project. That makes everything work fine, which was the case with my project. After some time though, for an unknown reason, something got corrupted in my Unit Test project and I started getting the error in the original post. To resolve this, I created a new Unit Test project, moved all of my unit tests to it, added a reference MSTest.TestFramework and deleted the one to Microsoft.VisualStudio.QualityTools.UnitTestFramework.
Here is a related issue.
Have you also referenced Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll? I don't see it in mentioned project references. This library is referenced in MS test projects by default though.
Also, see if the processor architecture of the tests and target project are same. Processor architecture of the test can be checked from menu Test->Test Settings->Default Processor Architecture. Possibly it would need to be changed to x64.
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