1

I am trying to use groovy scripts as BSF assertion in JMeter. The script written inside the JMETER assertion script box works well, but when I try to use it through a groovy file it is not loading the User Defined Variables it needs for assertions

It says

org.apache.bsf.BSFException: exception from Groovy: groovy.lang.MissingPropertyException: No such property: mobileNumber class: D__RESTAPITesting_JmeterBSFAssertionScripts_Script1

Not sure why it is looking for property when ${..} refers to a variable (if I am not wrong). Any help on the error message and how to use a script file for assertions ?

The scripts I have written are saved as *.groovy. Do I need to save scripts in some other extensions for BSF to read it correctly ?

3
  • Not that it solves your issue or anything, but you should always prefer using a JSR223 step over a BSF step. I think BSF is an older implementation of the newer JSR223?
    – djangofan
    Jan 26, 2015 at 15:59
  • Yes you are right. I am shifting from BSF to JSR223. But dont't know if we have any automated technique to do that. i.e. I have test plans with around 150 BSF (Assertions/post-/pre-processors). Dont want to invest time in changing each an every BSF to JSR of them manually until and unless we have any functional blocker (like Apache stops having BSF in further releases...). So the task is having a low priority right now. Feb 2, 2015 at 3:27
  • Yep, no need to refactor what already had worked.
    – djangofan
    Feb 2, 2015 at 4:07

1 Answer 1

0
  1. Pass your User Defined Variables via Parameters input like ${foo} ${bar}
  2. In your .groovy script body refer variables as args[0] args[1]

See image below for details (the solution works fine for file inputs as well) and How to Use JMeter Assertions in 3 Easy Steps guide for advanced information on using JMeter's assertions.

enter image description here

1
  • In my case I will be using almost all (more than 10) UDVs I see script box is using some variable - "vars" . Any way I can use the vars object so that I can get access to all the UDVs Nov 20, 2014 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.