Forum Discussion

Kathryn_O_Malle's avatar
Kathryn_O_Malle
Contributor
16 years ago

Generic API call to list all properties for testCase...

Hi there,

Using the following code snippet I'm able to determine all of the assertions defined for a testStep:
def testStep = testRunner.testCase.testSuite.project.getTestSuiteByName(testSuiteName).getTestCaseByName(testCaseName).getTestStepByName(testStepName)
for (def i=testStep.assertionCount-1; i>=0; i--)
{
... some code here
}


What I would like to be able to do now is generate a list of all properties for a testCase? And could I also use the same method for testSuite, project, or even testStep?

Many thanks.
Adam Hall

NB: If this question looks familiar it was reposted due to unfortunate forum migration issues

4 Replies

  • Hi!

    try getting all properties in a TestCase with

    for( name in testRunner.testCase.propertyNames)
    {
    log.info( "$name = " + testRunner.testCase.getPropertyValue( name ))
    }

    the same looping should work for TestSteps as well..

    does that help?

    regards!

    /Ole
    eviware.com
  • Thanks for that. The original response also used the "each" construct, one I'm not yet familiar with. Do you know how the code would look using "each", and what the benefits of the "each" construct are?

    Many thanks
    Adam Hall
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Like this?

    testRunner.testCase.properties.each {
    log.info( "${it.value.name} = ${it.value.value}")
    }