jmeterjmeter-4.0jmeter-3.2

How to add Assertion in JSR223 using java


How to add assertion on response message in jsr223 postprocessor using java code.

I tried using AssertionResult.setFailure(true); but it is not working


Solution

  • Use JSR223 Assertion instead JSR223 PostProcessor

    JSR223 Assertion allows JSR223 script code to be used to check the status of the previous sample.

    You are missing calling setFailureMessage

    AssertionResult.setFailureMessage("Your reason for failure");
    

    The script can check various aspects of the SampleResult. If an error is detected, the script should use AssertionResult.setFailureMessage("message") and AssertionResult.setFailure(true).