sjkp
sjkp

Reputation: 35

How to fix 'Assertion failure:true' even if the expected and the actual are matching in JSON assertion in JMeter?

For a JSON assertion in JMeter 4.0, the expected and actual values are the same. But, in the JSON Assertion Result, it says it doesn't match. This was even compared in Excel to check for any spaces or additional characters and was found to match. Not sure why the assertion fails here in JMeter.

E.g.:

Assertion failure message: Value expected to match regexp '2019-03-25T16:06:36.162+0000', but it did not match: '2019-03-25T16:06:36.162+0000'

Upvotes: 0

Views: 587

Answers (2)

Dmitri T
Dmitri T

Reputation: 168082

  1. If you don't use a Regular Expression for data validation and it is rather a normal String - just untick 'Match as regular expression` box

    enter image description here

  2. If 2019-03-25T16:06:36.162+0000 is a regular expression - it is malformed as you need to escape the + sign with a backslash as + is a meta-character which needs to be escaped:

    enter image description here

  3. According to JMeter Best Practices you should always be using the latest version of JMeter so consider upgrading to JMeter 5.1 (or whatever is the latest version available at JMeter Downloads page)

Upvotes: 2

uru917
uru917

Reputation: 91

Do you have the option 'Match as regular expression' checked? If so, then you would need to escape the regular expression special characters (. and +) and replace your assertion value with 2019-03-25T16:06:36\.162\+0000

Upvotes: 1

Related Questions