testing - XML test scripts / runners -
is there xml testing frameworks out there allow me write scripts testing/asserting contents of xml file??
note: know such frameworks exist extensions programming language testing frameworks such java , .net.
what looking having independent of programming language. write xml testing scripts in notepad , not have compile them. (something dbfit xml). see below example of looking for.
sample xml
<parent> <value name ="bob"/> </parent> -->
sample xml test script
assert(xpath("/parent/value/@name") == 'bob');
you roll own solution using xslt.
here example of xslt evaluates assertion criteria , if not pass, uses xsl:message @terminate='yes' halt process , echo error message std out:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xd" version="1.0"> <xsl:template match="/"> <!--assert /parent/value/@name == 'bob'--> <xsl:if test="not(/parent/value/@name='bob')"> <!-- if not, terminate transform , fail --> <xsl:message terminate="yes">name must bob</xsl:message> </xsl:if> </xsl:template> </xsl:stylesheet> simply execute xslt against file(s) want validate.
Comments
Post a Comment