When I am testing my DAL I need to create some database entities before others because of dependencies, is there a way via method attributes or something I can make NUnit execute my tests in the order I specify ?
To order tests explicitly, NUnit provides an OrderAttribute . Tests with this attribute are started before tests without. The order value is used to determine the order to run the unit tests.
To run the same test fixture twice, in parallel, you need to pass strings as parameters into the TestFixture constructor. For example, the following code runs the test fixture once against an iOS device on a certain version and with a certain device description and a second time against an Android device.
Use Setup and Teardown methods in your tests. Create all the things you need for your test in a method marked with the [Setup] attribute. Use a method marked with a [Teardown] attribute to close your connections etc...
Ideally, executing tests in a specific order is against the philosophy of unit tests, where each test should be self contained and independent of the others.The reason why they are executed alphabetically is because reflection returns the methods in this order. Having said that, using Setup and Teardown methods will in a way help you. Having said all that, take a look at this links, it could be a bit of a read but the guy writing the article series has a point
LINK Pt1
LINK Pt2
LINK Pt3
LINK Pt4
LINK Pt5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With