A framework for testing XML

We need a framework that tests applications that produce XML as output.

This project requires expertise in XML, xpath and xml schemas.

A detailed spec is available.

A simple test suite for a simple "hello world" application that uses this framework is shown below. The hello world application is an application that responds to hello command.

This application can be run as

hello sayhello

This command generates the following output

<XMLResponse status="200" statusText="OK" xmlns="http://xmlconsole.org/2008-04/pc">





This application has been compiled and the executable is placed in folder "Release"

To be able to test this application using XMLUnitTest, the test cases must be defined and saved in a file. For this example, let's assume that the test case is helloworldtest.xml. For this example, let's assume that the desired test is checking whether the content of the "Hello" element is "XMLUnitTest".

<TestCase name="helloworldtest" xmlns="http://xmlunittest.org/2008-06/testcase#">


<Action name="sayhello" >

<Command path="Release/hello" args="sayhello">


<Assert method="Equal" check="/XMLResponse/body/Hello" value="XMLUnitTest" />





To run the testcase, the executable "xmlunittest" is used.

xmlunittest -case [url removed, login to view]

<XMLResponse status="200" statusText="OK" xmlns="http://xmlconsole.org/2008-04/pc">


<TestCaseResult name="helloworldtest" passed="1" failed="0" skipped="0" xmlns="http://xmlunittest.org/2008-06/testcase#">

<ConfigurationResult name="default" passed="1" failed="0" skipped="0">


<ActionTestResult name="sayhello" passed="1" failed="0" skipped="0">

<Command path="Release/hello" args="sayhello">


<AssertResult status="passed" method="Equal" check="/XMLResponse/body/Hello">











This output indicates that the Assert statement has been evaluated and the executable "Release/hello" has behaved as expected and generated a Hello element that contains the the text node "XMLUnitTest".

Kemahiran: XML

Lihat lebih lanjut: testing test, xml &, a name for, testing framework, test case, test applications, hello world, framework c, xml http, xml application, xmlns, testing content, http command, xml quot, schemas, statement application, test framework, method available, suite application project, xml simple, generates, check output, action name, testing text, Method Statement

Tentang Majikan:
( 121 ulasan ) Belfast, Ireland

ID Projek: #265395