SUT: ref Element

When nested inside a case or attribute element, allows that test to reference another test.

Each ref element identifies a test (via its id attribute) that is included into this test. That is, the referenced test case is activated when this test case is the current test. Test case referencing is not recursive. Reference multiple tests using nested ref elements.

Parameters

None.

Examples

<field xmlns:test="http://www.powerware.com/nz/XMLSchemaUnitTest">
   <tree>
      <leaf colour="green">
         <test:attribute id="yellow" name="colour" value="yellow" />
      </leaf>

      <test:case id="multiple" test="with" result="pass" desc="tree can have some yellow and some green leaves">
         <leaf colour="yellow">
            <test:attribute name="colour" value="red" result="pass" desc="Leaves can turn red once a leaf has fallen">
               <test:ref>yellow</test:ref>

               <test:ref>fallen</test:ref>
            </test:attribute>
         </leaf>
      </test:case>
   </tree>

   <test:case id="fallen" test="with" result="pass" desc="Leaves may fall in autumn when all leaves are yellow">
      <test:ref>yellow</test:ref>
      <test:ref>multiple</test:ref>
      <leaf colour="yellow"/>
   </test:case>
</field>

This creates three test cases:

  1. tree can have some yellow and some green leaves (should pass validation)
    <field xmlns:test="http://www.powerware.com/nz/XMLSchemaUnitTest">
      <tree>
        <leaf colour="green"/>
        <leaf colour="yellow"/>
      </tree>
    </field>
  2. Leaves can turn red once a leaf has fallen (should pass validation)
    <field xmlns:test="http://www.powerware.com/nz/XMLSchemaUnitTest">
      <tree>
        <leaf colour="yellow"/>
        <leaf colour="red"/>
      </tree>
      <leaf colour="yellow"/>
    </field>
  3. Leaves may fall in autumn when all leaves are yellow (should pass validation)
    <field xmlns:test="http://www.powerware.com/nz/XMLSchemaUnitTest">
      <tree>
        <leaf colour="yellow"/>
        <leaf colour="yellow"/>
      </tree>
      <leaf colour="yellow"/>
    </field>

Return to main page.