I have 30 test cases in the 'EmployeeSchema'. I want to know in which order the test cases run in the tSqlt? If I know the order of execution of test cases, then I alter the execution order of my test cases one after another. Kindly advise.
-- Runs all the tests on MyTestClass
EXEC tSQLt.Run 'EmployeeSchema';
When running all tests within a test class,
tSQLt.Runwill run the tests in "random" order, meaningtSQLtleaves the order up to SQL Server and how it retrieves the data. Although, it shouldn't matter which order they run in since each test should be independent in and of itself.If for some reason you want to run individual tests in a different order you will need to run
tSQLt.Runseparately for each individual test in whichever order you want. You can't specify a particular order when you calltSQLt.Runfor an entire test class.Note: thanks to @Sebastian Meine for correcting me
To confirm it is
randomexecution plan dependent, here is the cursor declaration fromtSQLt.Private_RunTestClassthat pulls the list of tests within the requested test class. There is noORDER BYso SQL Server will return the test names in whichever order it sees fit.