InfoQ

News

Article: Unit-Testing XML

Posted by Stefan Tilkov on Jun 11, 2007 06:11 AM

Community
Agile,
Java,
SOA
Topics
Delivering Quality,
Unit Testing,
Software Testing
Tags
XMLUnit,
Validation,
XML,
TDD,
Testing
There are many occasions where software creates XML output:  XML documents are used for data interchange between different applications, web application create (X)HTML output or respond to AJAX requests with XML, and this has to be tested as much as anything else.

The major problem with testing operations that produce XML results is to decide whether the result is correct or not, since a simple textual comparison is not enough.

In this exclusive InfoQ article, XMLUnit and Ant contributor Stefan Bodewig explains how to write tests in the presence of XML, showing detailed example scenarios and how to approach them with the help of the XMLUnit Java framework.

5 comments

Reply

Is there an equivalent SoapUnit ? by anjan bacchu Posted Jun 11, 2007 4:59 PM
Re: Is there an equivalent SoapUnit ? by Steve Loughran Posted Jun 12, 2007 4:19 AM
Re: Is there an equivalent SoapUnit ? by Stefan Bodewig Posted Jun 12, 2007 5:15 AM
Re: Is there an equivalent SoapUnit ? by Andreas A Posted Jul 10, 2007 3:37 AM
The listings are a bit cumbersome... by Krzysztof Witukiewicz Posted Nov 28, 2007 4:45 AM
  1. Back to top

    Is there an equivalent SoapUnit ?

    Jun 11, 2007 4:59 PM by anjan bacchu

    Hi There/Stefan, Seems to be an useful tool. I've used my home grown xml utilities for command line validation of xml files. command line usage : I recently came across validate-xml.jar from woodstox "xml Processor" project. This seems to be a decent tool that points out where in an xml file a warning/error lies -- sort of like a compiler output. It would be nice to have a good WebServices/SOAP Unit Testing tool for the java world. Is there one ? I will be working on a project where I will be developing(exposing) some web services as well as consuming some. It will be nice to have a tool that will test my webservices before the actual client interop tests. What will be nice is to have a) a command-line client to test some basic webservices functionality like validity, list operations, etc b) something like XMLUnit which helps in junit/TestNG unit tests. What do people in the .NET world do ? Thanks BR, ~A

  2. Back to top

    Re: Is there an equivalent SoapUnit ?

    Jun 12, 2007 4:19 AM by Steve Loughran

    Anjan, 0. Ant has to check XSD files; Jing has a relax NG validation task. 1. You can use XMLUnit under TestNG as well as JUnit. 2. SOAP testing? Why would we need to test SOAP? I dont think its really time to improve the testing/debug facilities in SOAP land, because after so many years, you still end up using a TCP trace tool to work out why your messages arent being understood by the far end. Better to start working on the tools we need to make testing RESTy systems easier. Sorry :) -Steve Steve Loughran, Ant development team, Author of Ant in Action

  3. Back to top

    Re: Is there an equivalent SoapUnit ?

    Jun 12, 2007 5:15 AM by Stefan Bodewig

    as for SOAP specific testing tools, I'm not aware of any. People in the .NET world use NUnit or MBUnit (very few may use Team Test) - together with XMLUnit for .NET, I hope.

  4. Back to top

    Re: Is there an equivalent SoapUnit ?

    Jul 10, 2007 3:37 AM by Andreas A

    soapUI worked pretty good for testing our webservices. Tests can be extended with groovy scripts for automatic input/output transitions between test steps

  5. Back to top

    The listings are a bit cumbersome...

    Nov 28, 2007 4:45 AM by Krzysztof Witukiewicz

    ...because xml tags are interpreted by the browser :/ If anybody has better 'viewing experience', then please tell me what app do you use (I tried Firefox 2.0, IE6 and Opera 9.02)

Exclusive Content

VMware Infrastructure 3 Book Excerpt and Author Interview

VMware Infrastructure 3: Advanced Technical Design Guide and Advanced Operations Guide provides a wealth of practical insights into setting up virtualization in todays corporate environments.

Architectures of extraordinarily large, self-sustaining systems

Can a system that is so large it cannot be comprehended be "designed" in a conventional sense? The foundations of computing are about to change. In this talk, Richard P. Gabriel explores why and how.

Using Ruby Fibers for Async I/O: NeverBlock and Revactor

Ruby 1.9's Fibers and non-blocking I/O are getting more attention - we talked to Mohammad A. Ali of the NeverBlock project and Tony Arcieri of the Revactor project.

Agile and Beyond - The Power of Aspirational Teams

Tim Mackinnon talks about the aspirations behind the Agile principles and practices, the desire to become efficient, to write quality code which does not end up being thrown away.

Concurrency: Past and Present

Brian Goetz discusses the difficulties of creating multithreaded programs correctly, incorrect synchronization, race conditions, deadlock, STM, concurrency, alternatives to threads, Erlang, Scala.

ActionScript 3 for Java Programmers

Often the hardest part of changing technologies is language syntax differences. This new article provides Java developers with a transition guide to Actionscript which forms the foundation of Flex.

Neal Ford On Programming Languages and Platforms

Neal Ford talks about having multiple languages running on one of the two major platforms: Java and .NET. He also presents the advantages offered by Ruby compared to static languages like Java or C#.

Future Directions for Agile

David Anderson talks about the history of Agile, the current status of it and his vision for the future. The role of Agile consists in finding ways to implement its principles.