views:

160

answers:

3

I know you generally should not depend on order for your unit tests, but in xunit is it possible to make your tests run in a certain order?

+1  A: 

No, I don't believe so, but then unit tests by definition should be independent so order shouldn't matter. Where you do have a natural dependency you can't separate I'd suggest you combine the tests into one unit with multiple asserts.

annakata
+1  A: 

xUnit.net does not provide a way to order tests.

Some other frameworks do, however. For example, in mbUnit, you can attach an Order property to your test attributes. Many TDD purists feel that this is abusive, and any test that requires an order should be merged into a separate unit test, but many people find it useful to be able to order tests in certain circumstances.

Reed Copsey
+4  A: 

There is a sample in our Samples project named PrioritizedFixtureSample which allows you to control the ordering of tests.

See the samples in our latest release: http://xunit.codeplex.com/Release/ProjectReleases.aspx

Brad Wilson