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

Categories

0 votes
2.9k views
in Technique[技术] by (71.8m points)

Are there any advanced options of setting values of properties in jmeter properties file

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

.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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...