Why my NUnit tests execute in different order than they are listed?
And upon what the execution order depends?
Why my NUnit tests execute in different order than they are listed?
And upon what the execution order depends?
It depends on how the runner arranges them after reflecting on your test assembly. Each runner may do this differently.
For instance, Reshaper's runner runs alphabetically.
But the salient issue here is that NUnit tests should not have sequential stipulations or dependencies.
If you need to have tests depend on other tests, use MbUnit. This is an example of fixture dependency using the DependsOnAttribute.
Any unit test runner will probably reflect over the test fixture class and search for all methods with a certain attribute applied (or which matches some naming convention). The order these methods are returned does not depend on the order they are specified in the source file, so they cannot be executed in the order they are defined. This shouldn't be a problem since unit tests should run independently from each other.
They are run alphabetically as mentioned. If you open a test dll in the GUI NUnit runner you'll see the ordering.
Despite this, the order in which unit tests are run should not matter. A unit test should be isolated and independent, thus order should be no issue.