sonya_m
5 years agoSmartBear Alumni (Retired)
[TechCorner Challenge #1] How to add a new tag and assign it to all TestCases in a TestSuite?
Hi Community!
As you know, we have a TechCorner label, a place where tons of useful information about ReadyAPI is stored. We would like to make this section even bigger.
I would like to enc...
- 5 years ago
Task: Create a script, that can add a new tag and then assign it to every TestCases in a TestSuite.
This is a solution created for [TechCorner Challenge #1]
Here's a groovy script that will take a Test Suite name, and then iterate through each test case to add that name. Can be adapted to go through each test suite too, easily enough.
// set up project level variable def project = context.testCase.testSuite.project; String tagName = "DesiredTagName"; // Add desired tag name to project project.addTag(tagName); // get tagId of added tag String tagID = project.getTagId(tagName); // set up desired test suite, by name. def testSuite = project.getTestSuiteByName("test"); for (int i = 0; i < testSuite.getTestCaseCount(); i++) { // get test Case object by index def tc = testSuite.getTestCaseAt(i); // assign the tag tc.assignTag(tagID); }