Menu

Space in comparison

2008-03-17
2013-03-03
  • Waldemar Sojka

    Waldemar Sojka - 2008-03-17

    Hello

    I want two compare two xmls. SetNormalizeWhitespace is true and:
    - expected is <name>value</tag>
    - actual is <name> value</tag>

    Should my test fail? As I understand comparison should work like this " value" is different from "value".
    And even with whitespace normalization because this should only change few white spaces to one.

    Thanks
    Waldemar

     
    • Stefan Bodewig

      Stefan Bodewig - 2008-03-18

      Yes, you should expect your test to fail.

      SetNormalizeWhitespace(true) implies DocumentBuilder.setIgnoringElementContentWhitespace(true) but I wouldn't expect this to affect whitespace between the opening element and the non-whitespace text content.

      I assume it passes or otherwise you wouldn't be asking this question, right?

       
      • Stefan Bodewig

        Stefan Bodewig - 2008-03-26

        Well, it's only been a year or so since I implemented it and I forgot how I did.

        If you set normalizeWhitespace to true, XMLUnit will trim all text content - and the user guide actually says so.  See http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#Comparing:%20Configuration

        So, sorry for the confusion: you should expect the values to be identical.  Testcase removed and Javadocs modified to mention the fact.

         
    • Stefan Bodewig

      Stefan Bodewig - 2008-03-18
       
    • Waldemar Sojka

      Waldemar Sojka - 2008-03-18

      Yes, it fails :)

      Thanks

       

Log in to post a comment.