W3C home > Mailing lists > Public > public-xformsusers@w3.org > November 2017

TestSuite 2.0

From: Steven Pemberton <steven.pemberton@cwi.nl>
Date: Mon, 06 Nov 2017 10:30:00 +0100
To: " XForms" <public-xformsusers@w3.org>
Message-ID: <op.y89zcao3smjzpq@steven-xps>
I've made some more changes, in particular I'm changing tests to be  
self-checking as much as possible (not always possible, because sometimes  
you have to visually check the results).

For example, go to the Functions chapter, and click through the examples.  
You will see a few with a big green PASS.

These have a generic form. The instance contains a number of <test>  
elements. The content of the test elements are the parameters to the  
function being tested.
Each test element has a @req attribute, which is what the result should  
be, and a @res attribute which is calculated with a bind. For instance,  
for boolean-from-string:

	  <tests xmlns="">
	    <test res="" req="true">true</test>
	    <test res="" req="true">TRUE</test>
	    <test res="" req="true">tRue</test>
	    <test res="" req="true">1</test>
	    <test res="" req="false">false</test>
	    <test res="" req="false">FALSE</test>
	    <test res="" req="false">faLse</test>
	    <test res="" req="false">0</test>
	    <test res="" req="false">test</test>
	    <test res="" req="false"></test>
	<bind ref="test/@res" calculate="boolean-from-string(..)"/>

Then there is a <pass/> element that is bound via a calculate, and it  
checks that the count of the elements where @res=@req is the same as the  
count of all elements.

	<bind ref="pass" calculate="if(count(../test[@res = @req])=count(../test),
				    'PASS', 'FAIL')"/>

The body of the form just displays the req and res attributes.

       <output class="{pass}" ref="pass"/>
       <repeat ref="test">
	<output ref="."/> → <output value="@res"/><output class="wrong"  
value="if(@res != @req, ', WRONG', '')"/>

This means:
1. it is really easy to add extra tests (add a new <test> element to the  
2. the file is generic: you only have to change the <test> elements, and  
the calculate on the test/res bind.
3. It is REALLY easy to see if a test passes or fails, and if it fails,  

(Not all tests have been updated to this style, but I'm working on it).

Received on Monday, 6 November 2017 09:30:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:37:48 UTC