Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I got test.properties file for my jmeter test. It contains some enviro property=value pairs and those work nicely.

But I would like to add something like this:

a1 = value
b1 = value

a2 = a1+b1
b2 = value

a3 = a2+b2
b3 = value

When I use "hardcoded" value, like 10 for a2 and 20 for a3, the properties are loaded and used correctly. But a1+b1 does not work as required. Is there any way how to assigned sum of two properties as a value of another property?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

.properties file is just textual name-value pairs, it doesn't assume any evaluation logic.

  • If you need to sum 2 properties you need to go for __longSum() function like:

     ${__longSum(${__P(a1,)},${__P(b1,)},)}
    
  • If you need to store the result into another JMeter property - use __setProperty() function

     ${__setProperty(a2,${__longSum(${__P(a1,)},${__P(b1,)},)},)}
    

Demo:

enter image description here

More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

Also as per Configuring JMeter user manual chapter you shouldn't be using jmeter.properties file itself for extra configuration, it should go either to user.properties or external .properties file


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...