Reputation: 45
Execution order of RegisterTestFixture does not work. DUnitX executing test cases randomly. How do I determine execution order of the tests in DUnitX?
Upvotes: 2
Views: 357
Reputation: 1
Yes you are trying to use unit tests for integration testing. But this is not a bad thing, sometimes you have to hammer a nail with a screwdriver. I have run into this dealing with registering a DLL in different modes.(TrialMode, LicensedMode, ErrorMode) I needed to run the tests in a specific order to test all the results as setting the DLL to LicensedMode the DLL could not be set back to the TrialMode, but if I test TrialMode first then I can set and test for LicensedMode. You will need to break with the designed standard and take all your tests that need to run in a specific order and roll them into one test.
//[Test] // do not run in dunit test framework
Procedure TestTrialMode; // must run first
//[Test] // do not run in dunit test framework
Procedure TestLicenseMode;// must run second
[Test] // Do run this test
Procedure TestInCorrectOrder;
...
Procedure TestInCorrectOrder;
begin
TestTrialMode;
TestLicenseMode;
end;
This is not a pretty solution but tests are not pretty.
Upvotes: 0
Reputation: 21713
According to your comment you are doing some sort of integration testing which is totally fine to do with DUnitX.
However also integration tests should be self contained and not depend on other tests or their order. For tests on a database you usually have code in setup to prepare the data you want to run tests with and teardown to revert the database to a known state (if the database supports transactions that is usually a way to use them).
The setup and teardown code or parts of them can reused across several tests that do different tests on the same data.
Upvotes: 4