cancel
Showing results for 
Search instead for 
Did you mean: 

How to assert data from the response

Contributor

How to assert data from the response

Hi,

 

when i send a request, i want to assert some data in the response using "contains assertion"

 

my response is:

 

"data": {
  "ci_status_id": "023f8f0e-fc53-42ec-8348-24a5470b7d7b",
  "ci_name": "John",
  "updated_by": null,

   "created_at": "2016-02-15T13:53:20Z",
  "id": "6b54b04d-7d59-44bc-8f54-f439eebf5d1c"
},
"success": true
}

I want to assert :

ci_status_id  = this value is static

ci_status_name = this value is static

update_by =  this value is static

created_at = this value is current datetime

id = this value is dynamic and change for each request

 

What is did:

i added a datacource "values" and a datasource loop

in datasource i added a colum named "data"

in data, i added the content od data retrieved from the response

In my request, i added "contains assertion"  and added this line ${values#data}

 

Problem:

the request is successfull but the assertion is not good because "created_at" is false,

this value is dynamic.

So how can resole this problem

or i can ignore the value of created_at

 

Thank you

3 REPLIES 3
Community Manager

Re: How to assert data from the response

Hi Davy,

 

I think that you need to work with each property separately – data.ci_status_id, ci_name, etc.

 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Community Hero

Re: How to assert data from the response

It is not mentioned how the actual data is compared against the expected data.

In case of created_at, you can create a date before sending the request and the data from response should be greater than the date collected at the time of sending request.


Regards,
Rao.
Contributor

Re: How to assert data from the response

Hi,

this problem is not resolved

i'm tyring ...

New Here?
Join us and watch the welcome video:
Top Kudoed Authors