String comparison failure

Expected “this is a string for 2.000 €” is not equal to “this is a string for 2.000 €”

If you are writing tests and have string comparisons done, it can be sometimes tricky. Common problems are:

  • character encoding, eg. UTF-8 vs. ISO 8859-15
  • whitespace or non-visible (in your editor) characters at the end/beginning
  • non-breaking space characters, eg. in the example above between amount and currency