Which Unit-Testing Framework for .NET is the best?
-
I've been wondering which framework is the best to use on a green-field project. I know NUnit and MbUnit and noticed that MbUnit is better than NUnit, but I don't have any experience with xUnit.net. I have seen the controversial xUnit.net has caused with its introduction but so far I haven't found a review how it does really compare to the mature competition. It seems that only people with negative opinions about the xUnit.net design blogged about it without actually using xUnit.net. So does xUnit.net fall short from its promises? Are the perceived flaws it supposedly fixes real? Is there another framework I should look into before I'll stay with MbUnit?
Well I like nUnit. I have noticed that VS 2008 have some build-in testing stuff. Maybe that's worth checking out?
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand -
Debug.Assert()
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)When is using Debug.Assert() recommended? I do check my parameters but I throw exceptions here. Do methods using the conditional attribute survive the compilation even if the symbol isn't supplied there? If not it seems that one has to provide for libraries two versions.
-
Although my previous reply was not a joke, you could try Pex, it looks promising, but seems a bit complex to understand.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008) -
Well I like nUnit. I have noticed that VS 2008 have some build-in testing stuff. Maybe that's worth checking out?
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn RandNUnit isn't bad but MbUnit does support a few things better. There is even an old CodeProject article about an early version of MbUnit which explains the differences. Regarding the VS 2008 - firstly you have to use the team version and secondly I have heard only bad things about it. No one working with it seems to like it.
-
NUnit isn't bad but MbUnit does support a few things better. There is even an old CodeProject article about an early version of MbUnit which explains the differences. Regarding the VS 2008 - firstly you have to use the team version and secondly I have heard only bad things about it. No one working with it seems to like it.
AFAIK, unit testing was available in VS 2005 only for the Team System version, but in VS 2008, they made it available in Professional.
-
AFAIK, unit testing was available in VS 2005 only for the Team System version, but in VS 2008, they made it available in Professional.
Yup, I can confirm that. I have the plain vanilla pro version of vs 2008, and it's got testing built in. I don't use it, we've always used nUnit and there's no really reason to convert right now.
Simon
-
When is using Debug.Assert() recommended? I do check my parameters but I throw exceptions here. Do methods using the conditional attribute survive the compilation even if the symbol isn't supplied there? If not it seems that one has to provide for libraries two versions.
Debug.Assert should be used for: Expensive run-time checks that should not occur in release builds (e.g. in a binary_search function checking that the input range is actually sorted) Post Conditions Violating preconditions, as you said, should cause an exception to be thrown. Also, if verifying a post condition is extremely cheap (compared to the calculaiton itself), may be considered a candidate for an exception, IMO an assert makes more sense since it should surface durign testing, but not tax the release build. Sanity Checks If your five-if-cascade cannot possibly allow an x<0 to pass, verify it. This is similar to post conditions, but just for a block of code, not the entire function
OTOH, Debug.Assert IS the best Unit Testing Framework. It doesn't get any simpler. I am heavily using ASSERT's for C++ unit tests, since I find the added value of cppunit et. al. dubious. NUnit, OTOH, due to the .NET infrastruture can provide much better functionality so that I'd use that.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist -
When is using Debug.Assert() recommended? I do check my parameters but I throw exceptions here. Do methods using the conditional attribute survive the compilation even if the symbol isn't supplied there? If not it seems that one has to provide for libraries two versions.
-
I've been wondering which framework is the best to use on a green-field project. I know NUnit and MbUnit and noticed that MbUnit is better than NUnit, but I don't have any experience with xUnit.net. I have seen the controversial xUnit.net has caused with its introduction but so far I haven't found a review how it does really compare to the mature competition. It seems that only people with negative opinions about the xUnit.net design blogged about it without actually using xUnit.net. So does xUnit.net fall short from its promises? Are the perceived flaws it supposedly fixes real? Is there another framework I should look into before I'll stay with MbUnit?
I'm just using MSTest. :P Because it's integrated into VS2008, otherwise than that I just heard (a few different people said that) that it is comparable to NUnit feature-wise.
-
I've been wondering which framework is the best to use on a green-field project. I know NUnit and MbUnit and noticed that MbUnit is better than NUnit, but I don't have any experience with xUnit.net. I have seen the controversial xUnit.net has caused with its introduction but so far I haven't found a review how it does really compare to the mature competition. It seems that only people with negative opinions about the xUnit.net design blogged about it without actually using xUnit.net. So does xUnit.net fall short from its promises? Are the perceived flaws it supposedly fixes real? Is there another framework I should look into before I'll stay with MbUnit?
I like MbUnit better then NUnit and I haven't tried xUnit or MSTest. TestDriven.net is a cool addon for VS, especially the integration with NCover, and like others have brought up Pex looks interesting.
I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
-
I've been wondering which framework is the best to use on a green-field project. I know NUnit and MbUnit and noticed that MbUnit is better than NUnit, but I don't have any experience with xUnit.net. I have seen the controversial xUnit.net has caused with its introduction but so far I haven't found a review how it does really compare to the mature competition. It seems that only people with negative opinions about the xUnit.net design blogged about it without actually using xUnit.net. So does xUnit.net fall short from its promises? Are the perceived flaws it supposedly fixes real? Is there another framework I should look into before I'll stay with MbUnit?