Ask a Question

ReadyAPI 2.8 - Using Smart Assertion for data coming in different order

NickMitricka
Occasional Contributor

ReadyAPI 2.8 - Using Smart Assertion for data coming in different order

I'm testing a webservice that has the potential to return values in different order depending on execution.

Example below shows an array for the email object, where email[0] is not always the type = home.

{
   "emails" : [
      {
         "type" : "home",
         "value" : "testEmailHome@gmail.com"
      },
      {
         "type" : "work",
         "value" : "testEmailWork@gmail.com",
         "primary" : true
      }
   ]
}

Is it possible to utilize Smart Assertions to validate this scenario:

emails[*][type] == "home"
emails[*][type] == "work"

I know that I should always get 2 emails, but need to validate I'm getting one with type==work and one with type==home.

 

*Note - I know this can be done with other assertions, but I'm curious specifically about the Smart Assertion feature.

3 REPLIES 3
richie
Community Hero

Hi @NickMitricka 

 

I haven't used Smart Assertions myself - but it launches the Message Content Assertion assertion that was available in earlier versions of ReadyAPI! and I looked at trying to use this a while back.

 

Someone that knows the functionality better than I might have a different opinion, but I believe it doesn't support what you need it to do if I understand correctly.  Essentially you're saying the sequence of the type = home or type = work isn't constant - you know you'll get both in your response - but the sequence isn't fixed.

 

The problem I believe is that the Message Content Assertion assertion uses XPATH or JSONPATH (depending on the type of the response) to verify a certain attribute displays a certain value.

The 'Validation' column in the Message Content Assertion form doesn't provide any values that supports what you need.

 

As I say - someone who knows the functionality better might have a different opinion - but looking at it - I dont think so

 

@nmrao  showed me a couple of script assertions to handle what you want - but that doesn't help you I'm afraid

 

Cheers,

 

rich

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
nmrao
Community Hero

I am not aware of Smart Assertions and author of this question mentioned that he knows achieving what he needs using other ways.


Regards,
Rao.
richie
Community Hero

I understand - I was just highlighting that I think this is unachievable with the Message Content Assertion assertion

 

cheers,

 

rich

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
cancel
Showing results for 
Search instead for 
Did you mean: