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
Validation ,
TDD ,
XML ,
XMLUnit ,
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.

Related Sponsor

VersionOne is recognized by Agile practitioners as the leader in Agile project management tools. Companies such as Adobe, BBC, CNN, Dow, HP, IBM, Sony and 3M have turned to VersionOne to help deliver greater value to their customers.
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
Re: Is there an equivalent SoapUnit ? by Priyanka Grover Posted Sep 17, 2008 6:24 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)

  6. Back to top

    Re: Is there an equivalent SoapUnit ?

    Sep 17, 2008 6:24 AM by Priyanka Grover

    SoapUI is extremely good.

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.