Concordion > Commands > verifyRows >

Verify rows strategies

Since Concordion 2.0.0

The verify rows command implements a pluggable strategy pattern to apply different algorithms.

Built-in strategies are:

To apply a strategy, add the attribute concordion:matchStrategy="StrategyName" to the verify rows command element, where StrategyName is one of Default, BestMatch or KeyMatch.

You can also apply your own strategy by extending the org.concordion.internal.command.strategies.RowsMatchStrategy class, and setting StrategyName to the fully-qualified name of the class.

Examples

As a comparison, here is one example with each strategy applied. For more examples, see the specifications for the individual strategies.

Strategy Expected HTML Expected Table Actual Result HTML Result Table
Default
<table concordion:verifyRows="#user : users">
   <tr>
      <th concordion:assertEquals="#user.firstName">First Name</th>
      <th concordion:assertEquals="#user.lastName">Last Name</th>
      <th concordion:assertEquals="#user.age">Age</th>
   </tr>
   <tr>
      <td>John</td>
      <td>Smith</td>
      <td>22</td>
   </tr>
   <tr>
      <td>Jane</td>
      <td>Dou</td>
      <td>17</td>
   </tr>
</table>
{Jane,Smith,17};
{John,Dou,18};
{John,Smith,21}
<table concordion:verifyRows="#user : users"> <tr> <th concordion:assertEquals="#user.firstName">First Name</th> <th concordion:assertEquals="#user.lastName">Last Name</th> <th concordion:assertEquals="#user.age">Age</th> </tr> <tr> <td class="failure"><del class="expected">John</del> <ins class="actual">Jane</ins></td> <td class="success">Smith</td> <td class="failure"><del class="expected">22</del> <ins class="actual">17</ins></td> </tr> <tr> <td class="failure"><del class="expected">Jane</del> <ins class="actual">John</ins></td> <td class="success">Dou</td> <td class="failure"><del class="expected">17</del> <ins class="actual">18</ins></td> </tr> <tr class="surplus"><td class="failure"><del class="expected"> </del> <ins class="actual">John</ins></td><td class="failure"><del class="expected"> </del> <ins class="actual">Smith</ins></td><td class="failure"><del class="expected"> </del> <ins class="actual">21</ins></td></tr></table>
BestMatch
<table concordion:verifyRows="#user : users" 
concordion:matchStrategy="BestMatch"> <tr> <th concordion:assertEquals="#user.firstName">First Name</th> <th concordion:assertEquals="#user.lastName">Last Name</th> <th concordion:assertEquals="#user.age">Age</th> </tr> <tr> <td>John</td> <td>Smith</td> <td>22</td> </tr> <tr> <td>Jane</td> <td>Dou</td> <td>17</td> </tr> </table>
{Jane,Smith,17};
{John,Dou,18};
{John,Smith,21}
<table concordion:verifyRows="#user : users" concordion:matchStrategy="BestMatch"> <tr> <th concordion:assertEquals="#user.firstName">First Name</th> <th concordion:assertEquals="#user.lastName">Last Name</th> <th concordion:assertEquals="#user.age">Age</th> </tr> <tr> <td class="success">John</td> <td class="success">Smith</td> <td class="failure"><del class="expected">22</del> <ins class="actual">21</ins></td> </tr> <tr> <td class="success">Jane</td> <td class="failure"><del class="expected">Dou</del> <ins class="actual">Smith</ins></td> <td class="success">17</td> </tr> <tr class="surplus"><td class="failure"><del class="expected"> </del> <ins class="actual">John</ins></td><td class="failure"><del class="expected"> </del> <ins class="actual">Dou</ins></td><td class="failure"><del class="expected"> </del> <ins class="actual">18</ins></td></tr></table>
KeyMatch
<table concordion:verifyRows="#user : users" 
concordion:matchStrategy="KeyMatch"> <tr> <th concordion:assertEquals="#user.firstName"
concordion:matchingRole="key">First Name</th> <th concordion:assertEquals="#user.lastName"
concordion:matchingRole="key">Last Name</th> <th concordion:assertEquals="#user.age">Age</th> </tr> <tr> <td>John</td> <td>Smith</td> <td>22</td> </tr> <tr> <td>Jane</td> <td>Dou</td> <td>17</td> </tr> </table>
{Jane,Smith,17};
{John,Dou,18};
{John,Smith,21}
<table concordion:verifyRows="#user : users" concordion:matchStrategy="KeyMatch"> <tr> <th concordion:assertEquals="#user.firstName" concordion:matchingRole="key">First Name</th> <th concordion:assertEquals="#user.lastName" concordion:matchingRole="key">Last Name</th> <th concordion:assertEquals="#user.age">Age</th> </tr> <tr> <td class="success">John</td> <td class="success">Smith</td> <td class="failure"><del class="expected">22</del> <ins class="actual">21</ins></td> </tr> <tr class="missing"> <td>Jane</td> <td>Dou</td> <td>17</td> </tr> <tr class="surplus"><td class="failure"><del class="expected"> </del> <ins class="actual">Jane</ins></td><td class="failure"><del class="expected"> </del> <ins class="actual">Smith</ins></td><td class="failure"><del class="expected"> </del> <ins class="actual">17</ins></td></tr><tr class="surplus"><td class="failure"><del class="expected"> </del> <ins class="actual">John</ins></td><td class="failure"><del class="expected"> </del> <ins class="actual">Dou</ins></td><td class="failure"><del class="expected"> </del> <ins class="actual">18</ins></td></tr></table>