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.
diegomarconato
9 years agoOccasional Visitor
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