views:

87

answers:

2
+4  Q: 

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 here 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? Thanks!

+2  A: 

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. What this means is that 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 take no 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 3 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.

NerdFury
Yes, Nunit does have RowTest now. I have used both and they are very similar. MbUnit looks more pretty, lol.
Xaisoft
I won't post any answer here because I actively contribute to one of those project and my opinion is biased. But I would just like to mention that [Row] is not the only way to make data-driven tests in MbUnit. There are several other convenient data source attributes (http://gallio.org/wiki/doku.php?id=mbunit:data-driven_testing) such as [Column] and [Factory] among many others.
Yann Trevin
NUnit has several other ways of doing row based testing as well. One of my favorites being using a method name of a method that returns test data.
Martin R-L
+5  A: 

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

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 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.

Mauricio Scheffer
thanks for the answer.
Xaisoft