Both Should Be Equal
and Should Match
are used for verification in Robot Framework, but they serve different purposes and have distinct ways of comparing values:
Should Be Equal:
Should Be Equal
is case-sensitive for strings.${actual_value} Set Variable Hello
${expected_value} Set Variable Hello
Should Be Equal ${actual_value} ${expected_value} # Pass
${actual_value} Set Variable hello
${expected_value} Set Variable Hello
Should Be Equal ${actual_value} ${expected_value} # Fail (case-sensitive)
Should Match:
Should Be Equal
and is useful for verifying that a string conforms to a certain format or contains specific substrings.Should Match
is case-insensitive. You can use flags in your regular expression to make it case-sensitive if needed.${actual_value} Set Variable Hello, world!
${pattern} Set Variable Hello.*
Should Match ${actual_value} ${pattern} # Pass (matches the pattern)
${actual_value} Set Variable hello, world!
${pattern} Set Variable Hello.*
Should Match ${actual_value} ${pattern} # Pass (case-insensitive by default)
${actual_value} Set Variable hello, world!
${pattern} Set Variable (?i)Hello.* # (?i) flag for case-insensitive matching
Should Match ${actual_value} ${pattern} # Pass (case-insensitive)
Key Differences:
Feature | Should Be Equal | Should Match |
---|---|---|
Comparison | Strict equality | Pattern matching (regular expressions) |
Flexibility | Less flexible | More flexible |
Use cases | Exact value matching | Partial matching, format verification |
Case sensitivity | Case-sensitive (by default) | Case-insensitive (by default) |