Customizing the Requirements Trace Section

Many times, customers will want to modify the built-in requirements traceability report to display the names and descriptions of the requirements and test cases, instead of just displaying the IDs. For example, in this report, you get the names and descriptions:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:template match="/RequirementData">
    <table class="DataGrid" style="width:100%">
      <tr>
        <th>Req #</th>
        <th>Name</th>
        <th>Type</th>
        <th>Status</th>
        <th>Release #</th>
        <th>Test Traceability</th>
        <th>Requirements Traceability</th>
        <th>Requirement Description</th>
        <th>Test Case Name</th>
        <th>Test Case Description</th>
      </tr>
      <xsl:for-each select="Requirement">
        <tr>
          <td>
            RQ<xsl:value-of select="RequirementId"/>
          </td>
          <td>
            <xsl:attribute name="style">
              padding-left: <xsl:value-of select="string-length(IndentLevel)*2"/>px;
            </xsl:attribute>
            <xsl:if test="IsSummary='True'">
              <b>
                <xsl:value-of select="Name"/>
              </b>
            </xsl:if>
            <xsl:if test="IsSummary='False'">
              <xsl:value-of select="Name"/>
            </xsl:if>
          </td>
          <td>
            <xsl:value-of select="RequirementTypeName"/>
          </td>
          <td>
            <xsl:value-of select="RequirementStatusName"/>
          </td>
          <td>
            <xsl:value-of select="ReleaseVersionNumber"/>
          </td>
          <td>
            <xsl:for-each select="TestCases/TestCase">
              <xsl:if test="position() > 1">,</xsl:if>
              TC<xsl:value-of select="TestCaseId"/>
            </xsl:for-each>
          </td>
          <td>
            <xsl:for-each select="Requirements/ArtifactLink">
              <xsl:if test="position() > 1">,</xsl:if>
              RQ<xsl:value-of select="ArtifactId"/>
            </xsl:for-each>
          </td>
          <td>
            <xsl:value-of select="Description" disable-output-escaping="yes"/>
          </td>
           <td>
            <xsl:for-each select="TestCases/TestCase">
              <xsl:if test="position() > 1">,</xsl:if>
              <xsl:value-of select="Name" disable-output-escaping="yes"/>
            </xsl:for-each>
          </td>
          <td>
            <xsl:for-each select="TestCases/TestCase">
              <xsl:if test="position() > 1">,</xsl:if>
              <xsl:value-of select="Description" disable-output-escaping="yes"/>
            </xsl:for-each>
          </td>    
          
        </tr>
      </xsl:for-each>
    </table>  
  </xsl:template>
</xsl:stylesheet>

When you run this report, you will see something like:

You can add references to test case custom properties. For example if you want to include custom properties:

  • Custom_01 (e.g. URL)
  • Custom_02 (e.g. Test Type)

you would add this to the XSLT template:

...
        <th>URL</th>
        <th>Test Type</th>
...
          <td>
            <xsl:for-each select="TestCases/TestCase">
              <xsl:if test="position() > 1">,</xsl:if>
              <xsl:value-of select="CustomProperties/CustomProperty[Name = 'Custom_01']/Value" />
            </xsl:for-each>
          </td>    
          <td>
            <xsl:for-each select="TestCases/TestCase">
              <xsl:if test="position() > 1">,</xsl:if>
              <xsl:value-of select="CustomProperties/CustomProperty[Name = 'Custom_02']/Value" />
            </xsl:for-each>
          </td>   
...

which would then give you: