Forum Discussion

davecoleman's avatar
davecoleman
Contributor
5 years ago
Solved

Groovy assert using Datasource value always returns false when correct

Hi, we have the following script pulling data from our DataSource excel to validate the response of the Status in the Response. The actual value is passed out (seen in the Datasink) and the input v...
  • nmrao's avatar
    5 years ago

    The data isource might be having value as "[HTTP/1.1 200 OK]" which includes the square brackets. is it?

    Then remove them ("[", "]") in the data source.

    Also, use below statement to assert

    assert trim(expectedHTTPResponse) == messageExchange.response.responseHeaders['#status#'][0]

    Or

    //define in source value as 200; say as below this makes life more easier
    def expectedHTTPStatusCode = '200'
    assert expectedHTTPStatusCode == messageExchange.response.responseHeaders['#status#'][0].split(' ')[1]