Friday 30 January 2015

Call/reuse a Beanshell function jmeter

1. Go to Jmeter bin folder.
2. Open BeanShellFunction.bshrc file.
3. Define a function you want call and save the file.
4. Open jmeter properties file and search for "beanshell.function.init=BeanShellFunction.bshrc"
5. Uncomment this line by removing # symbol at the beginning of the line and save the file.
6. Go to jmeter and select Function helper dialog from Options menu.
7. Select Beanshell from the drop-down (shown below).
8. Write your defined function name and parameter(if any) in the Expression to evaluate (shown below).
9. Click on Generate button.
10. Use the function string generated wherever you want to call the function(shown below).



2 comments:

  1. Hi Vikram ,

    Thank you for the post.

    Is this the only way to add custom functions in JMeter?Is there any possibility of writing a Beanshell function in the JMX file itself.If it is possible we can limit the changes made only on a single file?

    Thanks and regards
    Joseph

    ReplyDelete
    Replies
    1. Hi Josesph,

      In this approach, we are defining our method in .bshrc file and calling it wherever we need, if we want change something we should just change the defined function only once in .bhrsc file. Let me know if this is not what you are looking for

      Delete