Forum Discussion

Donkey2017's avatar
Donkey2017
Occasional Contributor
7 years ago
Solved

script assertion

Hi, not being a programmer could anyone suggest a way to check if the property "apples" has a number rather than just null for example. So below is the result of running a test. I can easily ask SOAP to check if there is an item called "apples" but I have no idea how to ask if "apples" equals a numerical value- any value not just 111.

{
   "CONTENT":    {

      "apples": 111,

   },

 

thanks

 

  • Donkey2017's avatar
    Donkey2017
    7 years ago

    Hi, thanks for the reply and since you have asked that question I suspect my question is a SOAP UI issue and so I posted to the wrong section (I think)

     

    cheers

6 Replies

    • Donkey2017's avatar
      Donkey2017
      Occasional Contributor

      Hi, thanks for the reply and since you have asked that question I suspect my question is a SOAP UI issue and so I posted to the wrong section (I think)

       

      cheers

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Just a matter of what tool you're using.  If you're using TestComplete to exercise this test case, then you're in the right place.  If you're using TestComplete to launch a SoapUI test, you might need to check with the SoapUI folks to see if they know better.

         

        For my part... that text content reads like JSON to me where you have an object with a property called "CONTENT" which consists of another object with a property of "Apples" which has a value of 111.

         

        SO.... what I would do in TestComplete is use the JSON.Parse method to parse that set of text into JavaScript objects and then just do a logic like

         

        if (CONTENT.Apples != '111') Log.Error('Nope');

  • Richard154's avatar
    Richard154
    Occasional Visitor

    Script Assertion technique is the most widely used technique since managing and maintaining hundreds of assertions are quite difficult for a long response message walgreenslistens