петак, 22. новембар 2013.

How to use java code in jmeter


Bean Shell Sampler - Using Java Code in Jmeter



Bean Shell Sampler allows simple way to use java code in jmeter tests.
Suppose, we extracted value from JDBC response and put in in variable expires_on (the first picture) and we should process it using java code (the second picture). We can do it as it shown




By default, Jmeter does not show values of variables defined in Bean Shell Sampler in View Result Tree listener. If you need to debug your test, and monitor values of variables in Java Code, you can use this little trick. Add the next two lines in Bean Shell Sampler:


import org.apache.jmeter.samplers;
import org.apache.jmeter.samplers.SampleResult;

SampleResult.setResponseData(nonce_expiration_date1 );
SampleResult.setDataType( org.apache.jmeter.samplers.SampleResult.TEXT );



Now, in View Result Tree listener, you can see value of nonce_expiration_date1 variable.




Нема коментара:

Постави коментар