Baljeet Bilkhu
Baljeet Bilkhu

Reputation: 103

JMeter Adding Variables

I need to add four variables in JMeter and store them in another variable that I will be using for a later request (to be stored in the variable finalScore. I have a BeanShell PreProcessor with the following code:

overallScore = ${__intSum(${score1}, ${score2}, ${score3}, ${score4}, finalScore)};

In executing, I keep getting the following error:

2015/10/16 14:05:05 ERROR - jmeter.JMeter:
Uncaught exception:  java.lang.NumberFormatException: 
For input string: "${score1}"

Any ideas on what is wrong and how to resolve?

Upvotes: 4

Views: 9821

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

  1. It looks like your ${score1} variable is not defined

  2. You need to remove spaces from __intSum() function, correct syntax is

    ${__intSum(${score1},${score2},${score3},${score4},finalScore)}
    
  3. You don't need Beanshell as sum of score1-4 will be stored as ${finalScore} If you need to have a sum of score1-4 and finalScore - amend your function as:

    ${__intSum(${score1},${score2},${score3},${score4},${finalScore},overallScore)}
    

References:

${__intSum(1,5,)} - will return 6

${__intSum(1,5,8)} - will return 14

${__intSum(1,5,8,SUM)} - will return 14 and store it to SUM variable

${__intSum(10,-5)} - will return 5

${__intSum(${A},${B})} - will return an evaluation of A and B variables integer representation sum, which can be handy for Counter value processing.

and extra information on the others.

Upvotes: 6

Related Questions