Menu

XMLUnit with JUnit 4.x?

Jeff Lanam
2010-05-20
2013-03-03
  • Jeff Lanam

    Jeff Lanam - 2010-05-20

    Has anyone tried using XMLUnit with JUnit 4.x?  I'm new to both products. I downloaded XMLUnit 1.3, found that I needed JUnit, and downloaded JUnit 4.8.2 binary.  I was able to create an Eclipse workspace and build XMLUnit, with one source change.
    The change was to examples\XPathRegexAssert.java, to change the import of junit.framework.Assert to org.junit.Assert.
    I suppose I can't used the new annotations of JUnit 4 with XMLUnit, but I would like to use them for other test cases. Any problems there? 
    Thanks.

     
  • Stefan Bodewig

    Stefan Bodewig - 2010-05-21

    XMLUnit can be used without using JUnit at all - as a library.  It is probably easiest to use it together with JUnit 4.x that way.

    What I mean is that instead of using

    assertXMLEquals(Diff d)
    

    you'd use

    assertTrue(d.similar())
    

    .

    I'm currently working on XMLUnit2 in svn and intend to provide JUnit4 integration via Hamcrest Matchers, but I'm not there (not yet and likely not withing reasonable time).

     
  • Anonymous

    Anonymous - 2010-05-21

    Thanks. I'd looked into it some more and come to that conclusion. It's good to see that XMLUnit is still being enhanced.

    Regards,
    Jeff

     

Log in to post a comment.