Implementing data table diffs to compare tables
Consider a situation where you need to verify an application response that is in the form of Table to another Data Table that we are sending in Feature file. This kind of verification is very common when we are testing REST services.
Based on what we have learned so far, we will break the Data Table down in the Feature file into a List of Lists, and then we will verify each element of those Lists with expected Lists (which we got after breaking the table). Let's understand how we can do this in an easier way.
How to do it…
For this recipe, consider the following Scenario:
Scenario: Table Diff Given user send a get request to "localhost:8080/e" Then user gets following response | username | age | | sham | 25 | | ram | 26 |
Now save the Feature file. After adding the following code to suggestions, this is how our Step Definitions will look:
@Given("^user send a get request to \"(.*?)\"$") public void user_send_a_get_request_to...