Follow @RoyOsherove on Twitter

Why MSTest is the IE6 of unit test frameworks

Someone asked me by email a couple of weeks ago, whether I still think NUnit is better than MSTest. I had two weeks to think about this before having enough time to write this.

keep in mind, I posted pretty much the same thing over a year ago. and NOTHING of that has changed since.

It’s hard to imagine just how little effort Microsoft has been putting into the idea of unit testing inside of mstest. 4 years after (or is it more?) it was concieved as an answer to things like NUnit (instead of adopting NUnit into visual studio), MSTest continues to be the fat, whiney kid in class,  where the only reason he has to be in that school is because his father donated a library to it.

Things mstest *still* doesn’t have, that exist in all other unit test frameworks:

  • Assert.Throws<T> like functionality. instead, it still supports the old way of using [ExpectedException]. even product teams working on asp.net mvc need to create their own helper methods to have the simple ability to assert that a specific line of code throws an exception. Just take a look at the tests for ASPNET MVC framework and you’ll find various ExceptionHelper classes.
  • TestCase - Ability to create parametrized , in place, tests such as NUnit’s [TestCase], or XUnit’s [Theory] . FYI, Data Driven Testing in MSTest is NOT what I consider the equivalent of that. it is good for range-tests, hundreds and thousands of test points, but not for unit tests, when you want your inputs as close to the test as possible. it is also horribly uneasy to start using DDT with mstest, because you’d also need to start “deploy”ing all those crap input excel files that contain 3 rows of simple data.

Things mstest does plain wrong:

  • it still has a bug with expected exception’s attribute “message” property that has not been fixed.
  • It does not allow abstract base classes for test classes

Here’s what really bugging me about mstest - these things have been true for several years and nothing has been done about them. MS really doesn’t care about unit testing, and their tools will actually force you to write worse unit tests.

It’s time to face facts :

MSTest is the IE6 of Unit Test Frameworks.

It’s big and bloated, doesn’t support upcoming standards for doing things better, slower, and you’re *sucked* into having to look at it sitting there, all day, just because you made the (lack of choice) to use Visual Studio for editing your .NET code. It’s NOT easily extendable, and it will only run tests written using mstest (Nunit can run mstest tests, BTW…)

If you really care about code quality, then mstest represents the opposite of paying attention to code quality for you. it represents neglect and uncaring. Don’t use it. Don’t, Don’t Don’t.

Update:

Here’s a video reply to some of the comments telling me how simple it is to add those features:

 

 

Upcoming 3 and 5 day TDD classes

TDD in .NET Day 3 Learnings