Forum Discussion

chathurad's avatar
chathurad
Contributor
6 years ago

How to say set accept any value greater than Zero

As on the image i can do an assertion for the node $.result and now its value is 4.

But is there any way where i can set this assertion to accept any value greater than Zero.

 

Eg: if the node $.result is having 6 then my currant assertion will get fail because its looking for 4.

 

Hope you can understand. Thanks.

 

2 Replies

  • JHunt's avatar
    JHunt
    Community Hero

    Hi,

    I don't know if that's possible with JsonPath Match assertion (I haven't used it much), but here's how you can do it with a Script assertion:

    def result = new groovy.json.JsonSlurper().parseText(context.response).'result'
    assert result > 0

     

    • chathurad's avatar
      chathurad
      Contributor

      oops, This is not possible with the given UI,

      To perform you suggestion i have to use script assertion.`


      JHunt wrote:

      Hi,

      I don't know if that's possible with JsonPath Match assertion (I haven't used it much), but here's how you can do it with a Script assertion:

      def result = new groovy.json.JsonSlurper().parseText(context.response).'result'
      assert result > 0