Atanoly
13 years agoOccasional Contributor
Multithreading in LoadTest
Hi colleagues.
Could you advise on the following.
I have a test case. When I loop test case to run continuously, the test case every next time increases one variable (set in TestCase Custom properties) and the test goes on.
Then I want to run test case in LoadTest mode say in 10 or 20 threads for 1000 seconds. And now I get an issue. Each thread runs the test with the same value of the variable.
My thought was the follow:
First test step of test case gets the variable and increases it in this manner:
def paymentCode //this is my variable
def a = context.ThreadIndex
paymentCode = testRunner.testCase.getPropertyValue("paymentCode") as int
paymentCode = paymentCode + a
It seems to be working.
During LoadTest the variable is unchangeable.
At the end of LoadTest I want to increase my variable on the number of tests that have been run during LoadTest so next time my LoadTest starts with new value of the variable.
For this in LoadTest tearDownScript I have this code
def paymentCode = loadTestRunner.loadTest.testCase.getPropertyValue("paymentCode") as int
paymentCode = paymentCode + 10 + context.RunCount
loadTestRunner.loadTest.testCase.setPropertyValue("paymentCode", paymentCode as String)
a = context.TotalRunCount
log.info "tottal runcount is: " + a
So, my varibale is getting increased by 10 only.
log.info a //gets NULL - means print out is NULL
Please help if you know sollution.
Regards,
Atanoly.
Could you advise on the following.
I have a test case. When I loop test case to run continuously, the test case every next time increases one variable (set in TestCase Custom properties) and the test goes on.
Then I want to run test case in LoadTest mode say in 10 or 20 threads for 1000 seconds. And now I get an issue. Each thread runs the test with the same value of the variable.
My thought was the follow:
First test step of test case gets the variable and increases it in this manner:
def paymentCode //this is my variable
def a = context.ThreadIndex
paymentCode = testRunner.testCase.getPropertyValue("paymentCode") as int
paymentCode = paymentCode + a
It seems to be working.
During LoadTest the variable is unchangeable.
At the end of LoadTest I want to increase my variable on the number of tests that have been run during LoadTest so next time my LoadTest starts with new value of the variable.
For this in LoadTest tearDownScript I have this code
def paymentCode = loadTestRunner.loadTest.testCase.getPropertyValue("paymentCode") as int
paymentCode = paymentCode + 10 + context.RunCount
loadTestRunner.loadTest.testCase.setPropertyValue("paymentCode", paymentCode as String)
a = context.TotalRunCount
log.info "tottal runcount is: " + a
So, my varibale is getting increased by 10 only.
log.info a //gets NULL - means print out is NULL
Please help if you know sollution.
Regards,
Atanoly.