08-28-2023 10:21 PM
What is best practice for when to use an If Statement vs Precondition to determine which code to run?
If Statement Example,
If A
then Run B;
If C
then Run D;
OR.............
Precondition Example For Same Code Above,
Precondition A then Run B
Precondition C then Run D
Thanks!
08-28-2023 10:31 PM
Depends on whether you want it to show explicitly or not.
Typically, you use IF statement if the logic is part of the test program logic and you use pre-condition if that logic is part of the framework.
08-29-2023 12:35 AM
To add to santo_13
I do prefer explicit IF statements in my test code. It ay bloat the code a bit, yet at the same time making it more readable.
Using PreConditions, things rather get hidden and vanish within in the settings coloumn of the Seqeunce Pane.
Same thing holds true e.g. for looping or synchronization settings.
Someone will have to debug the code.... do them (or yourself) a favour and leave something easy to read and understand.