ASP.NET MVC Unit Test

I would like to try a unit test in ASP.NET MVC framework. But I don't know which unit test framework I should choose.

NUnit, xUnit.net, MbUnit. or the unit test framework included in Visual Studio, which one is better?

0


a source to share


4 answers


If you're interested in following the BDD guidelines, I highly recommend xUnit.NET with Moq as a mocking framework. These two are some of the most promising and up-to-date unit testing units available these days, and together they make up both a powerful and flexible unit test framework. xUnit.NET is extremely extensible, as its Fact and Trait attributes can be extended with your own attributes, and the behavior of the test frameworks can be modified to suit your needs.

A great example of this flexibility is the ObservationAttribute and a supporting framework for testing BDD style using xunit.net, found here:



http://iridescence.no/post/Extending-xUnit-with-a-Custom-ObservationAttribute-for-BDD-Style-Testing.aspx

I use the aforementioned BDD style testing to create BDD tests of type Test-Class-Per-Unit for my ASP.NET MVC controllers (well, everything else I unit test too).

+1


a source


ASP.Net MVC doesn't create any specific framework requirements, any of them will work fine. NUnit is the most widely used and for this reason it is my default choice.

Once you get into unit testing, some of the other frameworks offer various advanced features that you can test.



I don't know anyone using the MS unit testing framework.

+1


a source


I would recommend starting with xUnit if you haven't used a testing framework before. It's hard to decide which structure is better, but I think xUnit is the "most modern" of NUnit, MbUnit and MSTest. Start learning xUnit from this article and then this

+1


a source


I am using MSTest :) so now you know one;)

Seriously, I think MSTest is the best framework to start with TDD. It is usable and it generates everything you need to wrap and most importantly it is integrated into visual studio ... so why don't you start with mstest and later you can switch to advanced frameworks with no problem.

In short, I would recommend MSTest.

amuses

+1


a source







All Articles