A Caution on Upgrading to VS2008 for MSTest
At my current client we use MSTest as our testing framework. Last week I was updating a solution that contained a few unit test projects from VS 2005 to VS 2008. The project upgrade wizard ran and everything compiled just fine. I ran the Unit test suite and noticed that several unit tests failed. I looked at the first test and noticed that it had an Assert.Inconclusive() operation in it at the end. Shouldn’t that mark the test as inconclusive and not failed? Odd.
The next oddity was that any test that had an ExpectedException attribute was failing indicating that the very exception I was looking for had been thrown. It was as if MSTest decided to completely ignore the ExpectedException attribute. Okay, now that’s double odd.
I tried creating a simple unit test in the existing test project that did nothing more than throw an exception and added the ExpectedException attribute. It still failed to notice the exception and instead reported the test as a failure.
One of the FTEs at the client used his VS2008 to generate the same simple unit test and it passed just fine. After that, I created a new unit test project and tried the same test on my box, also with a pass. At this point we decide it must have been something with the upgrade. After looking around on Google for a while I happen across this blog post by Joni Moilanen from Finland. Apparently the upgrade did not modify the version of the UnitTestFramework assembly the test project was using, it was still set to reference the 8.0 version. Once I updated it to point to the 9.0 version everything was ducky.
I understand the upgrade wizard not attempting to decide to update references for you on your projects, but I can also see where this type of reference should have been updated. Especially if the tests aren’t going to work under the newer IDE.
Lesson Learned: When you upgrade your MSTest projects to VS 2008 make sure to manually update the references to the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly to 9.0 as well.