From: Wolfgang M. <wol...@gm...> - 2006-07-31 15:20:16
|
I just added a few Ant scripts to better test eXist's web integration and HTTP-based interfaces. While the core database functions and the XQuery language are well-covered by automated tests, we still lack a dedicated test suite to ensure that all the application-level interfaces and especially the XQuery-Web integration work as expected. I have thus experimented with Canoo's WebTest (http://webtest.canoo.com) yesterday, which is basically just a set of Ant tasks to simulate a web client and test the behaviour of a web application. Writing tests is quite easy once you have a general skeleton, so I decided to integrate this into eXist. For example, the following code snip invokes test-modules1.xql and checks if the returned HTML response body contains <h1>PASS</h1>: <webtest name="testModuleImports2"> <config host="localhost" port="8080" protocol="http" basepath="exist/rest/db/webtest" summary="true" resultpath="${test.results}"/> <steps> <invoke description="REST: import module from database" url="test-modules2.xql"/> <verifyElementText type="H1" text="PASS"/> </steps> </webtest> To run the test suite, call Ant from within the root directory of your eXist installation: ./build.sh -f tools/webtest/build.xml The first time you run it, the script will try to download and install the required WebTest Ant tasks from the Canoo web site. It then starts a Jetty webserver and processes the tests. The queries for the tests are contained in directory webapp/webtest. After the test suite has completed, you will find a test report in test/webtest/html/results.html. Right now, the test suite contains just 6 simple tests like this to check module imports for the XQueryServlet/XQueryGenerator/REST. I'd like to encourage other developers to add more tests here. Wolfgang |