0
votes

I'm wanting to assert against JSON responses without using plugins on JMeter's BSF Assertions. For this purpose, I've created a simple set of util functions that cover my current use case: https://gist.github.com/formigone/410778976e01e0be3f572b43f331589b

My Question

What's a way to include my mini library globally within JMeter, so any BSF Assertion can have access to them?

I've tried adding the lib to a BSF PreProcessor in various scopes, but can't get it to work. I've tried putting it in a vars, but that only works in some of the threads.

1

1 Answers

0
votes

The only workaround I can think of is converting your utility code into Beanshell.

If you want to keep your JavaScript intact there is a possibility to call JavaScript code from Beanshell test elements like:

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
result = engine.eval("your JavaScript here");

Beanshell implementation in JMeter provides bsh.shared namespace which is globally available across all Thread Groups.

References: