Forum Discussion

armygrad's avatar
armygrad
Contributor
9 months ago

Assertions

Hi, is there any way of comparing an assertion of what is returned to data held in a data source i.e. an excel spreadsheet.
  • ChrisAdams's avatar
    ChrisAdams
    9 months ago

    You're almost there....

    Branch in brackets is undeclared, that's one issue.

    The other issue is that you're not pulling in the value from the test request response.

    You want to ensure that some value/node in your test request response matches some datasource value.  You have the datasource value in the variable datasourceDiary.  You need the one from the response.

    Use 'Get Data' to get the value of interest from the test request response.  If you call it 'valueFromResponse', then the IF would look like...

    if (datasourceDiaryRequest.contains(valueFromResponse) ) {

     The contains thing is a method that checks one string contains another.  E.g.

    
    "my source string".contains("source")   //returns true
    
    "my source string".contains("cat")   // returns false