Ask a Question

Ready API Data Driven Tests

SOLVED
lydeeea
Occasional Contributor

Ready API Data Driven Tests

Is there any way to set assertions for each row in my data source?

 

For example, my excel has 10 rows each with different data inputs.  I want to create different assertions for each of my 10 rows.

 

Thanks

3 REPLIES 3
ChrisAdams
Community Leader

Hi,

 

In my datasources, for each row, I tend to include the expected result(s) along with the values I intend to pass to an API call.  That way, I can pull the expected values from the row into the steps assertion or a Groovy script to assert/check response against the expected result.

lydeeea
Occasional Contributor

Thanks!

 

My expected results are not part of my input so will this still work?  I can have a column in my data source called results with what I'm expecting for that row?

 

 

Hi,

 

You can put whatever you want in your datasource file.

 

If one of things you want to assert is the same for every row, you don't need to put it in the datasource. E.g. status code should equal 200.

 

But, say, you want to check invalid responses as well as valid, then the datasource could be your mate.

 

For example.  Say you have a getCustomerDetailsById service...

 

CustomerId ExpectedStatusCode ExpectedSurname ExpectedForename
1 200 Lennon John
2 200 McCartney Paul
3 200 Harrison George
4 200 Starkey Richard
99 200 <null> <null>
ninetynine 500 <null> <null>

 

You can then have three assertions against your test step and dynamically compare expected result with the response.

 

You don't have to put your expected results in your datasource, this is just my favoured approach.

 

cancel
Showing results for 
Search instead for 
Did you mean: