installation
This is how to install and run XTest
- download the latest version of XTest
- unzip the contents to a folder
- run XTest.exe in a console or just double click
- open the generated HTML report
example
An example test script is included in the distribution. We included the following test sets.
<tests>
<namespace name="opensearch">http://a9.com/-/spec/opensearchrss/1.0/</namespace>
<group name="rss">
<server>http://www.beyondtrees.com/weblog/rss.xml</server>
<test name="rss">
<get/>
<assert select="/rss"/>
<assert select="/rss/channel/title" value="Beyond the Net"/>
<assert select="/rss/channel/opensearch:totalResults" op=">" value="200"/>
</test>
</group>
</tests>
In this script you can see
- a test with name "rss" is defined
- the URL to download from; the rss feed of my weblog
- several assertions to test for:
- there should be a document element "rss"
- the value of the "title" element should be 'Beyond the Net'
- the totalResults should be a number greater than 200
- note the inclusion of custom namespaces
command line
You may specify the test script filename on the command line. If none is specified, the file "test.xml" is used.
xtest.exe mytestfile.xmlIf you specify "-debug" on the command line, the application will generate debug level messages on standard out; this may be handy for debugging purposes
xml tags
the XML file can be formatted in different ways (the "tests" or "group" nodes are not needed or interpreted); but the following restrictions apply
A test should have a source definition, e.g. a "get" sub-element, and optionally a set of "assert" statements
- any "test" element (specifically, all nodes that can be found with the XPath "//test") will be executed, in order
- you may group tests functionally together by using "group" elements, to add assertions that should be executed for all tests in that group
test
The test element is the main element that defines a test, or a group of assertions on the same source. A test may have a "name" attribute that is used to identify it in the report.A test should have a source definition, e.g. a "get" sub-element, and optionally a set of "assert" statements
get
This element describes how to retrieve the source to test on. A get element may have a "url" attribute. If it has any ancestor nodes higher up the XML tree with the name "server", these values are concatenated. This allows you to define a single server in a test group, and have different tests specify only the last part of the URL.
<test>
<get url="http://www.google.com/search?q=test"/>
</test>
<group>
<server>http:://www.mycompany.com/test/</server>
<test>
<get url="service.jsp"/>
</test>
</group>
Any children elements of the "get" element are interpreted as request parameters and are properly encoded:
<get url="service.jsp"> <q>mytest</q> <lang>en</lang> </get>will result in a URL service.jsp?q=mytest&lang=en
assert
The assert element specifies the functional test, or what the application should look for. It can have the following attributes:- select (required): this is the XPath to test for; it may include XSLT XPath functions like count, sum, not
- value (optional): the value the select should evaluate to. If not specified, the test assumes that the XPath in @select means it should evaluate to true or to a non-empty nodeset. If the @value is surrounded by curly braces {}, the value XPath is actually evaluated on the tested document itself!
- op (optional): the operator to use for testing against the value; this can be "=", ">", ">=", "<", "<=" or "contains". If no operator is specified, the "=" operator is used
<assert select="/data/results/result"/>
<assert select="/data/results/result[@special='true']"/>
<assert select="/data/title" value="my title"/>
<assert select="/data/results/@total" value="241"/>
<assert select="/data/results/@total" op=">" value="200"/>
<assert select="/data/title" op="contains" value="test"/>
<assert select="count(/data/results/result)" value="241"/>
<assert select="count(/data/results/result)" value="{/data/results/@total}"/>
server
the server may be used to specify a common URL prefix for tests. The server element may have a @user and @password attribute to specify basic authentication parameters.<server>http://mycompany.com/application/</server> <server user="ceo" password="betty1981">http://mycompany.com/application/</server>
namespaces
to be filled in
tidying up dirty html
to be filled in
