Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSTest UnitTestingFramework 10.1 vs 10.0

I updated my reference for Microsoft.VisualStudio.QualityTools.UnitTestFramework in a test project from 10 to 10.1 and the expected exception doesn't seem to do it's job anymore. Try this for example ...

[TestMethod]
[ExpectedException(typeof(FileNotFoundException))]
public void SanityTest()
{
    File.ReadAllLines("TheresNoWayThisThingExists");
}

Test fails. If I revert back to 10 (have to undo), it passes. Anyone verify this or is it just me? I've tried it in resharper's test runner and ms test runner with the same result.

edit : additional info

It seems to know it passed ...sort of. Adding in a string value for 'noExceptionMessage' does NOT return that string value on failure.

Also AllowDerivedTypes seems to have no effect as well. (I swapped out FileNotFound to just Exception, same result)

like image 297
jeriley Avatar asked Mar 29 '11 17:03

jeriley


People also ask

What is the best unit testing framework for .NET core?

xUnit test is the best Unit testing framework for . Net programming languages like C#, VB.Net, and F#. xUnit derives its structure and functionality from SUnit of Smalltalk.

Is MSTest a unit testing framework?

MSTest is a number-one open-source test framework that is shipped along with the Visual Studio IDE. It is also referred to as the Unit Testing Framework. However, MSTest is the same within the developer community. MSTest is used to run tests.

How do I choose a unit test framework?

Determine what you want to focus on before jumping into testing. Identify the highest-priority application features or areas that must be tested. Identify a list of scenarios within each feature to test, and to consider which level of testing can fulfill each.

What is the difference between MSTest and Vstest?

There is a difference between vstest and mstest - the former is a test runner and the later is a test framework.


1 Answers

It happens when a project runtime version is v4.0.30319 and you change MSTest UnitTestingFramework from 10 to 10.1 which is v2.0.50727. There is no UnitTestingFramework 10.1 with runtime version v4.0.30319. So in order to fix it you need either change runtime version of the project or switch back to UnitTestingFramework 10.

like image 183
k0stya Avatar answered Nov 15 '22 11:11

k0stya