Forum Discussion

haneef's avatar
haneef
New Contributor
17 years ago

How to get the value of the cnt?

Hi,

I'm doing loadtest for a webservice. For each test I want to send a unique number.  The variable "cnt" shown in the statistics is enough for my task. I don't know how to get get the value of the variable in the groovy script.

Basically I want to do that following in my load
  1)  Create a property with initial value as 0
  2)  Update the value of the property via groovy with the value of "cnt"
  3)  Run the test with the value of the property

Don't know how to do 2). Any help is appreciated.

Thanks,
Haneef

1 Reply

  • Hello,

    You can fetch properties like this:

    def property = context.testCase.properties["Prop name"] // testCase level
    def property = context.testCase.testSuite.properties["test suite prop"] // testSuite level
    def property = context.testCase.testSuite.project.properties["project prop"] // project level

    to get property value :

    def propValue = property.value

    set property value:
    context.testCase.properties["Prop name"].value="new value"

    Hope this helps,

    robert