Forum Discussion

andrew_net's avatar
andrew_net
Occasional Contributor
9 years ago

BUG? JSONPath Match works differently between SoapUI open software version and SoapUI NG (Ready!API)

Hi,

 

We started with SoapUI open software version 5.2.1 and are now moving to SoapUI NG (Ready!API) 1.6.0.  Suddenly, our testcases began to fail. We then found that the JSONPath Match works differently between SoapUI open software version and SoapUI NG (Ready!API).

 

Given the following response:

 

{"errors": [{
   "code": "100",
   "message": "Message for 100",
  },

  {
   "code": "200",
   "message": "Message for 200",
  }

]}

 

The "JSONPath Match" assertion used to work on SoapUI open software version is as below

 

  Expression: $..errors[0].code

  Expected result: 100

 

This assertion fails on SoapUI NG (Ready!API). To pass on the NG version, the assertion has to be rewritten as below (note the highlighted square bracket):

 

  Expression: $..errors[0].code

  Expected result: [100]

 

Could anyone take a look and see if this is a bug? Thanks.

 

The problem is that we use both version cross different environments (some use open software version and some use NG version), as such that it requires the same test cases working on both environments.

 

Regards.

5 Replies

    • andrew_net's avatar
      andrew_net
      Occasional Contributor

      Thanks for the response, Rao.


      Unfortunately, it is not the same. What making the matter worse is that I tested more types of checking we are using and found more problems. For the same response JSON shown above, I created the following assertions:


      JSONPath Match:


      #1.1

        JSONPath: $.errors[0].code
        Expected value: 100

       

      #1.2

        JSONPath: $..errors[0].code
        Expected value: 100

       

      #1.3

        JSONPath: $..errors[?(@code == 100)]
        Expected value: [{"code":"100","message":"Message for 100"}]

       

      #1.4

        JSONPath: $..errors[?(@code == 100)].code
        Expected value: [100]

       

      #1.5

        JSONPath: $..errors[?(@code == 100)].message
        Expected value: [Message for 100]

       

      #1.6

        JSONPath: $..errors[?(@code == 300)]
        Expected value: []

       

      #1.7

        JSONPath: $..errors[?(@code == 300)].code
        Expected value: []

       

      #1.8

        JSONPath: $..errors[?(@code == 300)].message
        Expected value: []


      JSONPath Existence:


      #2.1

        JSONPath: $.errors[0].code
        Expected value: true

       

      #2.2

        JSONPath: $..errors[0].code
        Expected value: true

       

      #2.3

        JSONPath: $..errors[?(@code == 100)]
        Expected value: true

       

      #2.4

        JSONPath: $..errors[?(@code == 100)].code
        Expected value: true

       

      #2.5

        JSONPath: $..errors[?(@code == 100)].message
        Expected value: true

       

      #2.6

        JSONPath: $..errors[?(@code == 300)]
        Expected value: false

       

      #2.7

        JSONPath: $..errors[?(@code == 300)].code
        Expected value: false

       

      #2.8

        JSONPath: $..errors[?(@code == 300)].message
        Expected value: false

       

      The tests result are below:

       

      SoapUI (open software version):

       

        Passed: 1.1, 1.2, 1.3, 1.4, 1.5, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8

        Failed: 1.6, 1.7, 1.8 (these three test cases should also pass)

       

      Ready!API 1.5 and 1.6:

       

        Passed: 1.1, 2.1, 2.2

        Failed: 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8

       

      So the behaivor are really different! I will attach the test case to this post, could you please take a look? Thanks.

       

      To run the test case, please start the mock service and run the test suite "TestJSONPath".

       

      Regards.

       

      • nmrao's avatar
        nmrao
        Champion Level 3
        If you see the thread that I added above, it says they have problems around json path which is broken in 1.6 according to the topic author and I suggested to raise a case with support using the link provided.
        https://support.smartbear.com/product-list/