Lance Fisher
Lance Fisher

Reputation: 25813

In xUnit.net, is it possible to run tests in order?

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?

Upvotes: 21

Views: 14443

Answers (3)

Brad Wilson
Brad Wilson

Reputation: 70586

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: https://xunit.net/#releases

Upvotes: 15

Reed Copsey
Reed Copsey

Reputation: 564333

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.

Upvotes: 3

annakata
annakata

Reputation: 75794

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.

Upvotes: 5

Related Questions