Thursday 30 July 2009

How to make BeanShell work in JMeter

There was a section in JMeter tutorial on how to make BeanShell work in it. You can see section 2.2.7 in this page. But the section is not present at the moment I write this post. Maybe it should be like it is, because there is virtually one step to get it working.
To make BeanShell working you basically have to download one JAR file from BeanShell.org (I have downloaded bsh-2.0b4.jar) and place it in JMETER_HOME/lib directory.
After resterting JMeter and allowing it to read all the libraries it should work because lib directory is in JMeter's classpath.
There are some properties in jmeter.properties file e.g. beanshell.init.file if you need for example to define functions used in you BeanShell test elements.

Sometime it is difficult to troubleshoot problems with BeanShell test elements because JMeter omits Samplers that have bad BeanShell code. If you think your code should work, but it does not look into jmeter.log file. All errors are put there with sufficient description to get to know what is wrong with your code.

If you are using BeanShellSamplter it is good to use return statement with the data you want to observe. The value you returen will become the response of BeanShellSampler and you will be able to see it in View Results Tree and furthermore if it is an XML it can be shown as a tree.
Very goot explanation of what BeanShellSampler can do is in JMeter documentation. Look there.

2 comments:

  1. Thanks for sharing. For more information on Beanshell-enabled test elements and explanation of pre-defined variables along with JMeter API examples cookbook see How to use BeanShell: JMeter's favorite built-in component guide.

    ReplyDelete
  2. thanks for sharing
    kindly describe in deep explanation

    ReplyDelete