How to run Automated Tests based on conditional logic

Hoppertron
Giga Contributor

Is it possible to create a branching test suite which runs child Test Suite A if condition = X or runs Child Test Suite B if condition = Y?

Basically, I need to run a suite of tests which verifies the system configuration dependant on the instance name.

If the instance name is 'Dev' then it needs to check that system properties meet one set of system property values (e.g. css.$navpage-header-bg = "#000000"), but if the instance name is 'PreProd' then it needs to check a different of values for the same system properties (e.g. css.$navpage-header-bg = "#FFFFFF")

I was thinking of creating separate suites for Dev and PreProd, with an overarching parent suite.   The parent suite checks the instance name, and then only runs the appropriate child suite.

Is there any way to achieve this within the native Automated Test Framework behaviours, or can this only be achieved with scripts?

1 ACCEPTED SOLUTION

Sean Witt
Tera Guru

Hi Andrew.



This may give you a starting point to play around with in terms of approach...



1. I created "Test Suite A" as the parent of both "Test Suite B" and "Test Suite C"


2. My very first Test Step used for "Test Suite B" runs a record validation against the sys_properties table, checking the instance name value, which in your case would be Dev.


3. My next Test Step(s) would be whatever other tests you want to perform in the Dev environment.


4. Repeat #2 and #3 for "Test Suite C", but with a Value = PreProd (instead of Dev)




When I kickoff the parent suite, if I am testing in PreProd, that test step for the instance check will fail, skipping the rest of the Suite B steps, and then kickoff the Suite C steps, which should pass/work since I am in that instance. So in Dev I would run Suite B and fail/skip Suite C.



In quick testing, that approach works for me. Here's what the test step for the instance validation looks like:



Sample_test_step.PNG






Sean


View solution in original post

2 REPLIES 2

Sean Witt
Tera Guru

Hi Andrew.



This may give you a starting point to play around with in terms of approach...



1. I created "Test Suite A" as the parent of both "Test Suite B" and "Test Suite C"


2. My very first Test Step used for "Test Suite B" runs a record validation against the sys_properties table, checking the instance name value, which in your case would be Dev.


3. My next Test Step(s) would be whatever other tests you want to perform in the Dev environment.


4. Repeat #2 and #3 for "Test Suite C", but with a Value = PreProd (instead of Dev)




When I kickoff the parent suite, if I am testing in PreProd, that test step for the instance check will fail, skipping the rest of the Suite B steps, and then kickoff the Suite C steps, which should pass/work since I am in that instance. So in Dev I would run Suite B and fail/skip Suite C.



In quick testing, that approach works for me. Here's what the test step for the instance validation looks like:



Sample_test_step.PNG






Sean


Thanks Sean, that makes perfect sense and should do exactly what I need.