You need to sign in to do that
Don't have an account?
Sharath Chandra
Execution sequence of test methods.
if I have 5 test methods and a test setup method in a test class and when we perform a test run on this class, in what sequence will the test methods execute during the testing?.
Below is a sample test class.
This way you can guarantee that method1 is called before method2.
It does not matter the order in which they are called as each it a seperate transaction.
If you need the results fro the first method to be consumed in the second method, you will have to put the code together in the same method.
Thanks,
Swaraj Behera
I agree with swaraj.If you really need the results to be continued from first method and then second method you have to put the code at one place with in the same method.
The best way to understand the execution context is just assume a static apex method behaviour. Static methods don't have any state. Every thing executed within method is state full until the method exits.
Same thing happens in test classes everything executed between test methods block remain only for single transaction. Once the last execution finished everything reset to default. The only difference is test methods don't commit anything physically to database.
But during execution make sure that default behaviour of "run all test" is it executes all test methods in parallel so if there is a shared static method that query or insert record in object or custom setting then you may get exception due to conflicts.
Please mark it as solved if it helps you.
Best Regards,
Nagendra.P