I have a test that checks several objects in a table on our website. The test is written in SpecFlow and C#
It looks something like this:
When I click proceed
Then I should see the following values
| key | value |
| tax | 5.00 |
| delivery | 5.00 |
| subtotal | 20.00 |
My code behind for the "Then" step is something similar to:
[StepDefinition("I should see the following values")]
public void IShouldSeeTheFollowingValues(Table table)
{
var basketSummary = new BasketModel();
foreach (var row in table.Rows)
{
switch (row["key"])
{
case "tax":
basketSummary.Tax.Should().Be(row["value"]);
break;
case "delivery":
basketSummary.Delivery.Should().Be(row["value"]);
break;
case "subtotal":
basketSummary.Subtotal.Should().Be(row["value"]);
break;
}
}
}
The problem with this is in our build logs if the test errors it looks something like this:
When I click proceed
-> done: OrderConfirmationPageSteps.ClickProceed() (1.0s)
Then I should see the following values
--- table step argument ---
| key | value |
| tax | 5.00 |
| delivery | 5.00 |
| subtotal | 20.00 |
-> error: Expected value to be 5.00, but found 1.00.
as you can see above its hard to distinguish which object it means... when it says it expects it to be 5.00 Is there a way I can modify the output to say something along the lines of:
-> error: Expected value of Tax to be 5.00, but found 1.00.