marquillo
marquillo

Reputation: 87

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?

Upvotes: 0

Views: 464

Answers (1)

Dmitri T
Dmitri T

Reputation: 168207

.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

Upvotes: 1

Related Questions