Forum Discussion

blindahl's avatar
blindahl
New Contributor
2 years ago

JsonPath Match generates faulty Expected result

Using SoapUI 5.7.0, when using JSONPath Match to create an assertion for a example response like this:

{
    [
        {
            "id": 1,
            "name": "Kalle",
            "age": "12"
        },
        {
            "id": 2,
            "name": "Stina",
            "age": "14"
        }
    ]
}

 and your JSONPath Expression is:

$[*].name

and use "Select from current" button in the configuration dialog for JSONPath Match it generates

[Kalle, Stina]

Also, when using

$[*].age

it generates:

[12, 14]

And if you test these asserts in SoapUI it works just fine. But if I run ReadyAPI (payed version) which we use in CI (Jenkins) it reports error with the unfortunate error message (indicating that they are identical): 

[Comparison failed. Path: [$[*].age]; Expected value: [[12, 14]]; Actual value: [[12, 14]].]

The reason is that age is a string value but if you do

$[*].id

it generates

[1, 2]

and ReadyAPI validate that assertion just fine since id is an integer number. Is there a good reason for this or is it a bug that SoapUI "Select from current" generate faulty values for strings where it really should generate:

["12", "14"] and ["Kalle", "Stina"]

It would be more correct if the assertion SoapUI generates also failed in SoapUI which it doesn't now but also it would be so much more convenient if it generates an assertion that's correct given what the API respond with.

No RepliesBe the first to reply