I have a cleanup script that only needs to run after certain tests. I could hard-code all of the test case names into the @AfterTestCase section of the test listener, but that seems sloppy. Is there a way to surface the tags of test cases in the test listener?
1 Like
Figured out an answer to my own question. Here’s the answer for anyone else looking for it:
@AfterTestCase
def AfterTestCase(TestCaseContext testCaseContext) {
println testCaseContext.getTestCaseId()
println testCaseContext.getTestCaseStatus()
//Run Cleanup Script.
def testCase = findTestCase(testCaseContext.getTestCaseId())
if(testCase.tag.contains("Cleanup")) {
//Do Cleanup Stuff Here
}
}
2 Likes
Thank you for sharing your solution