A Test Suite is a dum bunch of Test Cases.
A Test Suite just executes TC1, TC2, then TC3. That’s all.
A Test Suite has no intelligence.
A Test Suite does not control the flow of composite Test Cases with if—then—else manner.
You should try “callTestCase()” keyword:
You will add a new Test Case “Controller”.
The Controller will call TC1, TC2, TC3.
The controller can know catch the result of TC2 exection and can control the flow.
suppose, somehow my 2nd case applyPromo got failed then the complete test case would be failed, and execution would be terminated from that point and the promo could not be deleted which is created earlier means the 3rd case deletePromo will not execute.
Within your called Test Case, applyPromo, you can use a “try / catch” block so if a part of it fails, the catch block gets control of your method (and could provide your method the return value). If your test case passes, then your catch statement does nothing. You can do different things based upon what specific exception was given. Below, I just used the generic Exception, however, you can maybe use, StepFailedException, or ElementInterceptionException, etc. and each catch statement can do something you want.
"applyPromo(some params)"
try {
blah
blah
boom boom bang
blah
} catch (Exception) {
// result = true;
}
result = true;
return result
}
Test Suite will invoke TC-1, TC-2 and TC-3 in this sequence regardles each test cases passed or failed. Even if TC-2 failed, the Test Suite will continue and will invoke TC-2.
When the Test Suite invoke TC-2, the TC-2 will check if the TC-1 has passed using the custom keyword assertTestCasePASSED(tcname). If the TC-2 finds that the TC-1 has passed, then the TC-2 will run normally. If the TC-2 finds that the TC-1 has failed, then the TC-2 will fail and skip its processing body.
Test Suite will invoke TC-3 regardless whether TC2 passed or failed. The TC-3 will check if the TC-1 has passed or not. The TC-3 will not check if the TC-2 has passed or not.
A Test Case is in effect an instance of Script class in Groovy language. A Groovy script can contain zero or more local Groovy methods . For example, the following Groovy script can be a valid Test Case with 3 methods:
def method1(String name) {
println "Hello " + name + ", I am the first case"
}
def method2(String name) {
println "How are you " + name + "?"
}
def method3(String name) {
println "Goodbye, " + name
}
method1("Poo")
method2("Poo")
method3("Poo")
When you run this Test Case, you will see an output in the console:
Hello Poo, I am the first case
How are you Poo?
Goodbye Poo
You can let your single Test Case to contain as many methods as you like. You can code anything in each methods.