Skip to content

Name the JSON types in JSON Assertion failure messages - #6935

Open
apoorv601singhal wants to merge 1 commit into
apache:masterfrom
apoorv601singhal:json-assertion-type-message
Open

apoorv601singhal wants to merge 1 commit into
apache:masterfrom
apoorv601singhal:json-assertion-type-message

Conversation

@apoorv601singhal

Copy link
Copy Markdown

Description

When the expected value and the extracted value have different JSON types, the JSON Assertion failure message now names both types. Same-type failures keep the old message.

Before: Value in json path '$.age' expected to be '8', but found '8'
After: Value in json path '$.age' expected to be number '8', but found string '8'

Motivation and Context

Fixes #5745. As discussed in the issue, the strict comparison is kept and only the message is improved, so users can see that "8" (string) and 8 (number) differ.

How Has This Been Tested?

Added a parameterized test in TestJSONPathAssertion covering number vs string, string vs number, boolean vs string, array vs number, and two same-type cases that keep the old message. The new type-mismatch cases fail without the change. Ran all tests in org.apache.jmeter.assertions and ./gradlew style with JDK 21.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.

When the expected value and the extracted value have different JSON
types, such as "8" and 8, the failure message printed both the same
way: expected to be '8', but found '8'. Mention the types in that case.

Fixes apache#5745
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JMeter 5.5: JSON Assertion fails when string is an Integer

1 participant