If you have preconditions, the test must fire them prior to the test logic. Never rely on the order of the tests. If there is particular data that needs to be set up for a test, you should set it up and then clean it after you are finished. This can be done in any testing library through setup and clean up methods. If your classes are fine grained enough, you can use the class setup and clean up methods, otherwise you have to focus on the test setup and clean up methods.
You could take the method of testing if things were set up (both methods fired?), but this can end up nullifying your test because one test was run in the "wrong" order. But since each test should be autonomous, there is not such thing as "wrong" order.
In your particular scenario, you should set it up to run in the order you needed tested. If all scenarios are valid, you need multiple tests. Here is what I mean by all scenarios (DS = DoSomething and DSE = DoSomethingElse):
Neither DS or DSE run
DS only
DSE only
Both, DS first
Both, DSE first
If different results are expected, by business rules, then you need all 5 tests. Rather than test for the order of the routines, your goal should be to be explicit about testing, forcing them to run in order.
If this cannot be accomplished in your tests, then I see two options:
- Re-architecting the solution to remove the "randomness"
- Adding some type of tracing for method order that can be queried