Forum Discussion

SuperSingh's avatar
SuperSingh
Contributor
6 years ago

Accessing Test Case Property in Project's TearDown script

 Hi All,    I was looking for groovy script to access property from test cases in the TearDown script (of Project) On doing GetData simply returns " context.expand( '${#TestCase#TCCount}' )" [T...
  • nmrao's avatar
    6 years ago

    SuperSingh ,

     

    What you have shown is the Teardown Script of Test suite, but not the project level Teardown.

     

    /**
    * Below is the Teardown Script of the Test Suite
    * which looks for the given property in all the test cases of the same suite
    * and logs the value
    **/
    
    //Specify your property name in below statement
    def propertyName = 'Property1'
    
    testSuite.testCaseList.each { kase ->
    		if (kase.hasProperty(propertyName)) {
    			log.info "${testSuite.name} suite, ${kase.name} case, ${propertyName} value is ${kase.getPropertyValue(propertyName)}" 
    		}		
    }