XUnit.NET aims to be the Next NUnit, but it's too soon

My blog has moved. You can view this post at the following address: http://www.osherove.com/blog/2007/9/21/xunitnet-aims-to-be-the-next-nunit-but-its-too-soon.html
Published Friday, September 21, 2007 7:48 PM by RoyOsherove


Saturday, September 22, 2007 2:03 AM by Brad Wilson

# re: XUnit.NET aims to be the Next NUnit, but it's too soon

Hey Roy, thanks for the comments. :) A common theme we were shooting for is simplicity. Here are some answers to your questions:

We did not forget Fail. We attempted to simplify a lot of things in the system. I personally believe that the need to use Fail() means there is probably a missing Assert, so rather than encouraging people to use Fail, I'd like to know what assert is actually missing.

I believe mocking frameworks are best left outside the unit testing framework. Everybody has their feelings on which they like best. Personally I usually hand-write stubs, but of all the ones I've used, I like Rhino best.

"Equals" is a static method on Object. We explicitly override it and mark it obsolete because its name is so close to "Equal", but it's not the same thing.

Generics can be implicitly instantiated. Assert.Equal("foo", "bar") works just fine, since the compiler knows that both are strings and automatically calls Assert.Equal<string> on your behalf.

For a while, we did have BeforeEachTest() and AfterEachTest() as part of ITestFixture, but we felt that leveraging the language as much as possible made more sense. Since we create a new instance of the test object for each test run, you can use the constructor and IDisposable.Dispose() in place of SetUp and TearDown.

We're going to devote a separate article soon to the process of migrating from NUnit, including the usage of our [RunWithNUnit] sample attribute in xunit.extensions.dll.

Thanks again!

Monday, October 1, 2007 5:44 AM by Paul Kohler

# re: XUnit.NET aims to be the Next NUnit, but it's too soon

Why not just add to NUnit? One of the main things I miss from NUnit compared to MBUnit for example is the RowTest attribute... but I would rather make a slight compromise in my test style and call methods from within my test than embark on a new framework!

I did put some effort into a "one line unit test" type framework last year but in practice then I was just using 2 frameworks. Unless theres a huge need I think it better to stick to the mainstream... my 2 cents ;-)

Wednesday, October 3, 2007 1:16 AM by Richard W

# re: XUnit.NET aims to be the Next NUnit, but it's too soon

I love the reduced syntax for xUnit.net. I definately feel that NUnit suffers from bloating tests with more syntax than is required. For example, I often do not require setting up or tearing down tests. If I do why do I need an attribute to do it, when the test framework can just use the constructor instead. Often I do not require most of the feature set that NUnit offers. NUnit is unnessasarily harder to learn than xUnit.net. Often I only want a simple test method. xUnit is a better testing framework to support.

Monday, October 8, 2007 6:29 PM by Chandra

# re: XUnit.NET aims to be the Next NUnit, but it's too soon

I think from a user point of view, use the one suits best in the situation you are testing.

I would still wait for xUnit.NET to mature because when I need some help, I can find a lot of information about nUnit then on xUnit.