简体   繁体   中英

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

我知道您通常不应该依赖于单元测试的顺序,但是在 xunit 中是否可以让您的测试按特定顺序运行?

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM