SUT: case Element

Creates a test case by including or excluding all elements within the case element.

SUT test cases can be nested, resulting in multiple test cases run from the outside in. If an outer test case fails, then all inner test cases are automatically failed since their result is no longer relevant.

An empty test case element is allowed.

A test case can be the document root.

Parameters

Attribute Description Required
test If with, include all nested elements that do not belong to the SUT namespace. If without, exclude all nested elements. Yes
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">
  <test:case test="with" result="pass" desc="items element can be empty" />
  <test:case test="with" result="pass" desc="items entry can contain an item">
    <item partNum="123-AB">
      <productName>TestProductName</productName>
      <test:case id="quantity" test="without" result="fail" desc="item must have a quantity">
        <quantity>1</quantity>
      </test:case>
      <test:case ref="quantity" test="with" result="pass" desc="item quantity can be 99">
        <quantity>99</quantity>
      </test:case>
      <USPrice>0.00</USPrice>
    </item>
  </test:case>
</items>

This creates four test cases:

  1. items element can be empty (should pass validation)
    <items />
  2. items entry can contain an item (should pass validation)
    <items>
      <item partNum="123-AB">
        <productName>TestProductName</productName>
        <quantity>1</quantity>
        <USPrice>0.00</USPrice>
      </item>
    </items>
  3. item must have a quantity (should fail validation)
    <items>
      <item partNum="123-AB">
        <productName>TestProductName</productName>
        <USPrice>0.00</USPrice>
      </item>
    </items>
  4. item quantity can be 99 (should pass validation)
    <items>
      <item partNum="123-AB">
        <productName>TestProductName</productName>
        <quantity>99</quantity>
        <USPrice>0.00</USPrice>
      </item>
    </items>

Return to main page.