JCMS
April 23, 2018, 4:09am
1
Hi guys, i’m a new beginner in automation tools and i need a help :# . Can anybody tell me how to skip a test case by condition? I have 5 test case in a test suite
1. TC A
2. TC B
3. TC C (I want this Test Case run depends on result on TC B. For example, if result X run this TC but if result Y skip this TC and go to next TC (D & E)
4. TC D
5. TC E
Thanks
2 Likes
As far as I see, a Test Suite is a simple sequence of invokations of Test Cases. No IF … THEN … ELSE … is achievable.
On the other hand, a test case can call other test cases. See
https://docs.katalon.com/display/KD/Call+test+case
And you can use Groovy’s native control of if (…) { … } else {…} in a test case. It quite easy.
So you can write your TC B so that B calls either of TC C or TC D+E depending on internal state of B.
Some bright guys are discussing about implementing workflow:
I have demonstrated the approach I used in my project as below. The idea was that I created my workflow test cases as generic as possible and all of them have neccessary params to perform the action. These params are passing over steps with the value from Data binding area. For example: my Test Data is an excel sheet having data for a list of username, password and profile. These value are row-by-row passing to the test case in test suite, and finally passing to Workflow Test case.
[image]
Tes…
2 Likes
I am unable to access the response to view reusable work flow…can someone help me with this…
Hi,
You can use Test Listener for this.
Step 1: Create Globalvariable TC_Status = “PASSED”
Step 2: - Create Test listener,
In, @After test
def sampleAfterTestCase(TestCaseContext testCaseContext) {
if(testCaseContext.getTestCaseId() == 'your test case'){
if(testCaseContext.getTestCaseStatus()=='FAILED'){
GlobalVariable.TC_Status = 'FAILED'
}
if(testCaseContext.getTestCaseStatus()=='ERROR'){
GlobalVariable.TC_Status = 'ERROR'
}
}
}
Step 3: Create testsuite.
In, @SetupTestCase :
@SetupTestCase (skipped = false) // Please change skipped to be false to activate this method.
def setupTestCase() {
// Put your code here.
if(GlobalVariable.TC_Status == “FAILED” || GlobalVariable.TC_Status == “ERROR”){
KeywordUtil.markErrorAndStop("---->|")
}
}
You can custom it for your access.
1 Like