When a scenario expects several tabular results, comparing values one by one can leave failures hard to diagnose. The data table assertion pattern compares expected and actual outcomes in one operation and reports all differences. section 14.6
A table comparison can make the assertion more useful and the step definition easier to maintain:
- Replace repeated field-by-field assertions with one comparison, supporting the atomic assertion principle. section 14.6
- Use the resulting table diff to see all mismatches; comparison APIs may differ in row ordering and supported table shapes. section 14.6
- Keep comparison logic separate from step-definition logic; where supported, treat null expected values as unspecified rather than comparing them. section 14.6
Listing 14.28 Test execution result on of a failing comparison
| name | price | original price | | Capricciosa | 7.99 | 8.99 | - | Pepperoni | 8.99 | 9.99 | + | BBQ | 8.99 | 9.99 |
A failed comparison makes the mismatch visible: the expected Pepperoni row differs from the actual BBQ row. section 14.6
