Forum Discussion
Not sure if I understand completely.
Assuming below scenario:
- A test case - containing a step - which uses property expansion such as <element>${#TestCase#UNIQUE_ID}</element>
- And the case can be executed many times as needed.
In this case, I may even not use the random number, instead I would go for a sequence like below
- Define two custom properties, say PREFIX, UNIQUE_ID
- Set Initial Value for PREFIX as say Test1, can be any of your choice. this will help you identify different test sets. you can change it to Test2, Test3 as needed.
- Set Initial Value for UNIQUE_ID as 0.
- Add the below script as Setup script of the test case. This reads existing value and increments it by one and store it back.
def val = context.testCase.getPropertyValue('UNIQUE_ID') as Integer context.testCase.setPropertyValue('UNIQUE_ID', (val+1 as String))
In the test request of test case, use as <element>${#TestCase#PREFIX}_${#TestCase#UNIQUE_ID}</element>
The above would generate values incrementally as Test1_1, Test1_2 etc.,
NOTE:
This does not require any additional test steps
Coveat is that you need to run test case always in order to get the incremented value, not run as individual test step.
Hope this helps.
My problem is that I use UNIQUE_ID several times in the SOAP request of the Test Case.
So it happens that I generate two different UINIQUE_ID. I want to create the same again UNIQUE_ID
- rupert_anderson9 years agoValued Contributor
So another way of saying what you want is when your TestCase is run:
- You want to generate a unique id (once per TestCase run)
- Then use that id multiple times in the same TestCase execution without the value changing.
- On the next run of the TestCase, a new id will be generated
Does this make sense and match what you want?
If so please see either my or Rao's answer. Mine uses a Groovy TestStep at the beginning, his uses a setup script - both achieve the same result.
Regards,
Rup
- nmrao9 years agoChampion Level 3Even this description is confusing your use case. May be would you consider explaining it with an example so that it would be clear?
Related Content
- 5 years ago
Recent Discussions
- 2 days ago
- 2 days ago