How to get testcases list added in TestSuite at runtime?

Does anyone know how can I get the list of test cases we have added in the test suite at run time?
@Russ_Thomas please help if it is possible.

Here is a method/keyword I use every day.

/**
   * Returns a string containing references to all Test Cases found in the
   * specified Test Suite.
   *
   * @param suiteName (String) The Test Suite to be examined.
   * @param before (String) Typically used to pass HTML to the output.
   * @param after (String) Typically used to pass HTML to the output.
   * @return String.
   */
  static String getSuiteTests(String suiteName, String before = "", String after = "") {
    int count = 0
    String projDir = RunConfiguration.getProjectDir()
    String fname = projDir + "/Test Suites/" + suiteName + ".ts"
    comment("getSuiteTests reading: " + fname)
    String xmlText = new File(fname).getText()
    comment("getSuiteTests parsing: " + fname)
    def testList = new XmlSlurper().parseText(xmlText)
    String output = ""

    testList.testCaseLink.testCaseId.each {
      count++
      output += before + count.toString() + ": " + it.toString() + after + "\n\n"
    }

    return output
  }

As the comments suggest, I use it to produce HTML output for reporting purposes:

    String testsInSuite = getSuiteTests(suiteName, "<tr><td>", "</td></tr>")

image

1 Like

Thanks @Russ_Thomas

1 Like