cancel
Showing results for 
Search instead for 
Did you mean: 

how to add multiple values in Contains Assertion

Visitor

how to add multiple values in Contains Assertion

how the values should be seperated. request 1 will depend on request to if the response has all 8 values. Do I need to add assertion for each single value ?

8 REPLIES 8
Community Hero

Re: how to add multiple values in Contains Assertion

Unclear. Can the question be more specific possible with any example or screen shot etc?


Regards,
Rao.
New Contributor

Re: how to add multiple values in Contains Assertion

Hi Rao,

 

I am also trying to do what the original user was asking. This is where you have your request set up, You are on the Assertions tab, and you wish to add in multiple/a list of assertions in One "Contains Assertion" check.

 

So, how do you separate each value you wish to check for?  OR are you only able to add one Contains Assertion value per Assertion?

 

Thanks, James

Community Hero

Re: how to add multiple values in Contains Assertion

Not sure I got it quite right. It is general practise that, there should be a separate assertion for each value. This is really helpful to know in case of failures.


Regards,
Rao.
New Contributor

Re: how to add multiple values in Contains Assertion

Thanks Rao.

 

It was simply a case where I wished to check a list of field were being returned within my json response, and creating individual assertions for each field is a lengthy step.

 

I'm sure there is a quicker way to check a list of results, but as a new user to the tool, I'm yet to discover how to.

Community Hero

Re: how to add multiple values in Contains Assertion

Can you show the input response, and expected data that you want to compare?
Can't image what exactly you are talking about.


Regards,
Rao.
New Contributor

Re: how to add multiple values in Contains Assertion

I've attached an image showing the json response, and then the List of individual assertions I added to ensure I'm being returned all expected fields.

 

As you can see, I've added the field assertions individually (32), which would have been quicker to have added all expected fields in one assertion.

Community Hero

Re: how to add multiple values in Contains Assertion

I would go for Script assertion in such case.

See if below example would fit the bill.
http://stackoverflow.com/questions/36631111/how-assert-parameter-name-without-value-using-groovy/366...


Regards,
Rao.
Contributor

Re: how to add multiple values in Contains Assertion

Having individual assertions is the standard approach. But if you still wish to do that, you can't do that on Contains assertion. But you can use XPath assertion and have Contains function

Your declaration would be: 

contains(//*:ResponseFiled, "ValueToValidate1") and contains(//*:ResponseField, "ValueToValidate2")

Expected would be: true

 

Hope that helps

New Here?
Join us and watch the welcome video:
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win