Forum Discussion

lydeeea's avatar
lydeeea
Occasional Contributor
3 years ago
Solved

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...
  • ChrisAdams's avatar
    ChrisAdams
    3 years ago

    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.