tests in XML [Re: Re: PULL Parser in PHP]
Aleksander Slominski <[email protected]>
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Message-ID | <[email protected]> |
hi,
disregard previous email as it is incomplete (wrong key pressed ...)
read this one instead - it is complete ...
lrargerich wrote:
> Good I'll see your work by monday and send ideas/suggestions thinking
> about a XSLT implementation. I guess that the XML test docs should be
> delivered as strings maybe in CDATA sections of the XML test vocabulary.
>
> Then it will be easy to write a XSLT stylesheet , something like this:
>
> <test name="initial test">
> <xmlsource><![CDATA[ <foo></foo> ]]>
> <testCode>
> <createParser/>
> <setFeature name="BLAH" value="blah />
> <expect type="START_DOCUMENT" nameNS="" localname="" />
> <execute method="next()"/>
> <expect type="START_TAG" nameNS="" localName="foo">
> <execute method="isEmptyElement()" into="t1" />
> <assertVar name="t1" value="true" />
> <execute method="next()"/>
> <expect type="END_TAG" nameNS="" localName="foo" />
> <execute method="next()"/>
> <expect type="END_DOCUMENT" nameNS="" localName="" />
> </testCode>
> </test>
>
> For methods returning values we can use
> <execute method="getName()" into="foo">
> <assertVar name="foo" value="root">
>
> execute executes a method and if into is defined assigns the return
> value of the method to the variable indicated by name in the into
> attribute.
that unfortunately looks to close to programming language and i am
just a bit scared that it is too flexible - it is not possible
check that wrong method is executed
<execute method="getFoo()" into="foo">
> into indicates the name of a variable, assertVar tests if a variable
> has the desired value if not it throws an exception.
however the main problesm is that to execute this XML i would need
to maintain variables in hashtable, use reflection to execute functions
and generally start something similar to programming language
(for example in java it is necessary to maintain correct type checking ...).
also how to pass parameters to methods (such as require) or declare
exception handling?
so i am afraid it may be too complex to implement correctly and if it is implemented
partially then we can run in all kinds of problems like some tests
can not be executed in Java but can be in XSLT (or PHP or C++) testing engine
> Then a test case is easy to run if no exceptions then test=ok ,
> exceptions may come from the parser (example an expect that fails) or
> from failed asserVars.
i think that exception testing is required but for first version we can
just concentrate on positive conformity testing i.e. any exception
thrown indicates error
> It will be important to keep the test vocabulary as minimalistic as we
> can so the XSLT stylesheets are simple and easy to write allowing test
> cases in many different languages.
i am not experienvced with XSLT so could you describe what is
execution model you want to use? do you want to generate
source code (for exmple in PHP) and then compile and execute
tests?
so the question is what is the most strict and simplest possible XML
desciption that can be used by simple Java tester and in XSLT.
do you think that XML fragment below could be transformed with XSLT?
thanks,
alek
<tests xmlns="http://xmlpull.org/v1/tests/2002-08.xsd">
<test name="initial test">
<input-inline><![CDATA[ <foo></foo> ]]></input-inline>
<createParser/>
<set-feature>http://xmlpull.org/v1/doc/features.html#process-namespaces</set-feature>
<expect type="START_DOCUMENT" nameNS="" localname="" />
<next>
<!-- instead of:
<execute method="next()"/>
-->
<expect type="START_TAG" nameNS="" localName="foo" isEmptyELement="true">
<!-- instead of:
<execute method="isEmptyElement()" into="t1" />
<assertVar name="t1" value="true" />
-->
<next/>
<expect type="END_TAG" nameNS="" localName="foo" />
<next/>
<expect type="END_DOCUMENT" nameNS="" localName="" />
</test>
</test>