Search code examples
jmeterbeanshell

How force BeanShell Assertion to make verified result is shown in View Result Tree of JMeter?


I am using JMeter for testing:

How force BeanShell Assertion to make verified result is shown in View Result Tree?

I tried Log but it is not shown in View Result Tree:

props.put("result",vars.get("matchingIdCount_1"));

print(props.get("result"));
log.info("---------------------------");
log.error("error");

Solution

  • log shorthand will append message to jmeter.log file only, it won't be visible in any listener. To be able to see it in View Results Tree you need to amend response code, message, headers or data.

    For example if you change your script to:

    SampleResult.setResponseMessage("result -> " + vars.get("matchingIdCount_1"));
    

    You'll be able to see the value in "Response Message" section:

    Sample Result Beanshell Response Message

    SampleResult is a pre-defined variable which provides access to parent/associated SampleResult class instance methods and fields.

    See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more Beanshell and JMeter related tips and tricks.