I use JavaScript to parse my JSON result in BSF Assertion. For more reusability, i try to write my own JavaScript library. I would like use the library in my BSF Assertion.
Maybe i misunderstand the documents, i cannot find anyway to import my library in BSF. Dose only BeanShell provide this kind of method to import external script? (http://jmeter.apache.org/usermanual/functions.html#__BeanShell)
I even try another way but in vain.
1.Create BSF PreProcessor and put my library (named: myScript) in it.
function test(){
log.info("Test Library");
}
2.Import the code and invoke it,
${__BeanShell(vars.get("myScript"))};
test()
But it doesn't work .. :(
Any idea?
You can use JSR223 PreProcessor Choose Javascript language
Include your library using for example __FileToStringjsCode and put it in UserDefinedVariable:
jsCode / __FileToString(path to file)
In my example, file contains:
var s = "toto";
In you script:
${jsCode};
vars.put("toto", s);
Anyway I am not sure using Javascript is great for performances.
Groovy is a better option.