Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MbUnit vs. NUnit

I read that MbUnit is NUnit on steroids, but I don't see why. From what I have read on here, I hear that NUnit is more popular over MbUnit. One of the main reasons is because it has a fluent interface. Is this the only reason?

Why should I prefer MbUnit over NUnit, or vice-versa?

like image 811
Xaisoft Avatar asked Sep 09 '10 16:09

Xaisoft


2 Answers

Even though NUnit now includes the most popular MbUnit advanced features, MbUnit is still more feature-rich, for example:

  • Contract verifiers
  • XML assertions
  • Serialization assertions
  • External data sources (CSV, XML, etc.)
  • Parallelizable tests

Fluent interfaces may be nice, but in general they don't add any new features. They just present things to the programmer in a different way.

NUnit is more popular because it was there first (therefore there are more articles about it on the web, and better tooling), and because most programmers don't care about or need the advanced features that MbUnit offers.

like image 92
Mauricio Scheffer Avatar answered Nov 20 '22 20:11

Mauricio Scheffer


NUnit started as a port of JUnit, and has been around a long time. MbUnit came after the fact, and it brought "generative" unit testing. This means it has the ability to take a single unit test and generate several from it. One way to do this is the [RowTest] attribute.

Where a typical unit test will not take any parameters, a RowTest will take parameters and generate multiple tests from that. I believe that NUnit has the concept of RowTest now as well.

[Test]
[Row(1, 1, 2)]
[Row(2, 2, 4)]
[Row(1, 2, 3)]
public void X_plus_Y_equals_Z(x, y, z)
{
  Assert.AreEqual(z, x+y);
}

This will result in three tests being run in the test runner. There are also features for rolling back database transactions.

NUnit has the fluent interface for assertions, which is nice, but not really a selling point. NUnit probably also has some better tool support (ReSharper's test runner works with NUnit out of the box, but requires plugins for MbUnit).

In the end, you should pick one framework and go with it. The skills you pick up are very portable from one framework to another.

like image 33
NerdFury Avatar answered Nov 20 '22 19:11

NerdFury