0

I am using Jmeter and I am testing if a JSON response from a GET request is correct by using JSR223 Assertion.

When the script is correct then the results are correct (unless of course there is something wrong with the response). However if the script is incorrect the test fails even though that the response is accurate, which is the expected behavior.

But then I have to check each line of the script so that I can find the differencies with the response in order to fix it. This wastes a lot of time.

I am not speaking of missing symbols but rather additional lines that are compared to the JSON response but are not actually in it. For example I am comparing country code in the assertion but there is no country code in the response.

Is there a way that JSR223 Assertion can return the differencies in the debugger for Jmeter?

Thank you in advance!

D.Angelov
  • 189
  • 3
  • 10

1 Answers1

0

You have AssertionResult shorthand which is an instance of AssertionResult class therefore you can use the following methods:

Example code:

if (1 == 1) {
    AssertionResult.setFailure(true);
    AssertionResult.setFailureMessage("Expecteed something but it wasn't found");
}

Will produce output like:

JMeter JSR223 Assertion custom message

More information on using JMeter Assertions: How to Use JMeter Assertions in Three Easy Steps

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • I am using groovy. How to import the package in order to get the failure resuts? Also is there a way to see in the results where exactly is the problem? – D.Angelov May 22 '17 at 08:58
  • 1
    What package? `AssertionResult` can be used right away, you don't need any import statements. – Dmitri T May 22 '17 at 09:07