jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz KoŇĄczyk <grzegorz.konc...@marketplanet.pl>
Subject changing User Defined Variable using script in BeanShell PostProcessor
Date Mon, 07 Apr 2008 14:01:58 GMT
My TestPlant looks like this:

TestPlant
  |-User Defined Variable
  |-HTTP Request
    |-BeanShell PostProcessor

TestPlan settings are:
Number of threads: 1
Ramp-up: 1
Loop: 1

In User Defined Variable I have 2 variables defined:
offer = 100
step = 2

In BeanShell PostProcessor I have following script (print functions are only for "debugging"):

print( ${offer} );
int of =  Integer.parseInt( vars.get("offer") );
int st = Integer.parseInt( vars.get("step") );
of = of + st;
String newVal = Integer.toString( of );
print( newVal);
vars.put( "offer", newVal ); 
print( ${offer} );

The console output (black cmd window opened while starting JMeter) shows me following results:

100
102
100 - here is the error - why it's not 102 here?

AFAIK, vars.put( "offer", newVal ); should overwrite old value of "offer" (100) with the new
value (102), but it doesn't.

I tried also another way:


import org.apache.jmeter.util.*;

print( ${offer} );
int of =  Integer.parseInt( vars.get("offer") );
int st = Integer.parseInt( vars.get("step") );
of = of +st;
String newVal = Integer.toString( of );
print( newVal);
JMeterUtils.setProperty( "offer", newVal );
print( ${offer} );

But it also gives me:

100
102
100 (why not 102 ??)

Any ideas?


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Mime
View raw message