SUT: attribute Element

Creates a test case by adding, modifying or deleting an attribute in the containing element.

Parameters

Attribute Description Required
name The name of the attribute being added, modified or deleted to form the test case. Yes
value The value of the attribute for the test case. If absent, the attribute is deleted. No
result

If pass, the test passes if the resulting test case passes validation. If fail, the test passes if the resulting test case fails validation. Note that in the latter case, it does not matter why the test case fails. Logging should be used when the test case is created to ensure that validation fails for the correct reason.

If omitted, then this test case is not executed. This is usually because the id attribute has been specified and this test is referenced by another test (that is, this test is not a complete, independent, test).

No
desc The test name or description. Yes, unless the result attribute is omitted.
id Identifies this test so it can be included into another test using the ref tag. No
ref Identifies a test (via the 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. No

Parameters specified as nested elements

ref

Where there is more than one other test to be referenced, multiple ref elements may be used.

Examples

<items xmlns:test="http://www.powerware.com/nz/XMLSchemaUnitTest">
  <item partNum="123-AB">
    <test:attribute id="partnum" name="partNum" result="fail" desc="item must have a partNum attribute" />
    <test:attribute name="partNum" value="12A-AB" result="fail" desc="item must have a well formed partNum attribute" />
    <test:attribute ref="partnum" name="productName" value="TestProductName" result="fail" desc="item cannot have a productName attribute instead of a partNum"/>
    <productName>TestProductName</productName>
    <quantity>1</quantity>
    <USPrice>0.00</USPrice>
  </item>
</items>

This creates three test cases:

  1. item must have a partNum attribute (should fail validation)
    <items>
      <item>
        <productName>TestProductName</productName>
        <quantity>1</quantity>
        <USPrice>0.00</USPrice>
      </item>
    </items>
  2. item must have a well formed partNum attribute (should fail validation)
    <items>
      <item partNum="12A-AB">
        <productName>TestProductName</productName>
        <quantity>1</quantity>
        <USPrice>0.00</USPrice>
      </item>
    </items>
  3. item cannot have a productName attribute instead of a partNum (should fail validation)
    <items>
      <item productName="TestProductName">
        <productName>TestProductName</productName>
        <quantity>1</quantity>
        <USPrice>0.00</USPrice>
      </item>
    </items>

Note that in these examples, there is no test case that partNum can equal 123-AB. It is usual for attribute elements to be nested inside case elements.

Return to main page.