Knowledge Base Article

Home Page > Knowledge Base > Spira Platform

Home Page > Knowledge Base > Spira Platform > SpiraTeam

Home Page > Knowledge Base > Spira Platform > SpiraTest

Article Creating a report to display test cases with execution counts

by Adam S on Tuesday, July 28, 2015

This articles describes the steps to create a custom report that displays a table of test cases with the following fields:
  • Test Case ID
  • Test Case Name
  • Last Execution Date
  • Last Execution Status
  • Number of Test Runs
Inside SpiraTeam or SpiraTest, go to Administration > System > Edit Reports.

Now do the following:
  1. Create a new custom report
  2. Give it a name and description
  3. You can leave the header and footer blank for now
  4. Enable the various formats that you want to be made available (typically include HTML and Excel for this kind of tabular report)
  5. Set the category as "Test Case Reports"
  6. Add a standard section. Choose the 'Test Case Details' as the section.
  7. Paste the XSLT code displayed below into the Template field
  8. Now save the section
  9. Now save the report

The XSLT template to use is as follows:

<?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="/TestCaseData">
    <table class="DataGrid" style="width:100%">
      <tr>
        <th>Test #</th>
        <th>Name</th>
        <th>Status</th>
        <th>Last Executed</th>
       <th>Execution Count</th>
      </tr>
      <xsl:for-each select="TestCase">
        <tr>
          <td>
            <xsl:value-of select="TestCaseId"/>
          </td>
          <td>
            <xsl:attribute name="style">
              padding-left: <xsl:value-of select="string-length(IndentLevel)*2"/>px;
            </xsl:attribute>
            <xsl:if test="FolderYn='Y'">
              <b>
                <xsl:value-of select="Name"/>
              </b>
            </xsl:if>
            <xsl:if test="FolderYn='N'">
              <xsl:value-of select="Name"/>
            </xsl:if>
          </td>
          <td>
            <xsl:value-of select="ExecutionStatusName"/>
          </td>
          <td class="Date">
            <xsl:call-template name="format-date">
              <xsl:with-param name="datetime" select="ExecutionDate" />
            </xsl:call-template>
          </td>
          <td>
            <xsl:value-of select="count(TestRuns/TestRun)"/>
          </td>
        </tr>
      </xsl:for-each>
    </table>
  </xsl:template>
  <xsl:template name="format-date">
    <xsl:param name="datetime"/>
    <xsl:variable name="date" select="substring-before($datetime, 'T')" />
    <xsl:variable name="year" select="substring-before($date, '-')" />
    <xsl:variable name="month" select="substring-before(substring-after($date, '-'), '-')" />
    <xsl:variable name="day" select="substring-after(substring-after($date, '-'), '-')" />
    <xsl:variable name="time" select="substring-before(substring-after($datetime, 'T'), '.')" />
    <xsl:variable name="monthname">
      <xsl:choose>
        <xsl:when test="$month='01'">
          <xsl:value-of select="'Jan'"/>
        </xsl:when>
        <xsl:when test="$month='02'">
          <xsl:value-of select="'Feb'"/>
        </xsl:when>
        <xsl:when test="$month='03'">
          <xsl:value-of select="'Mar'"/>
        </xsl:when>
        <xsl:when test="$month='04'">
          <xsl:value-of select="'Apr'"/>
        </xsl:when>
        <xsl:when test="$month='05'">
          <xsl:value-of select="'May'"/>
        </xsl:when>
        <xsl:when test="$month='06'">
          <xsl:value-of select="'Jun'"/>
        </xsl:when>
        <xsl:when test="$month='07'">
          <xsl:value-of select="'Jul'"/>
        </xsl:when>
        <xsl:when test="$month='08'">
          <xsl:value-of select="'Aug'"/>
        </xsl:when>
        <xsl:when test="$month='09'">
          <xsl:value-of select="'Sep'"/>
        </xsl:when>
        <xsl:when test="$month='10'">
          <xsl:value-of select="'Oct'"/>
        </xsl:when>
        <xsl:when test="$month='11'">
          <xsl:value-of select="'Nov'"/>
        </xsl:when>
        <xsl:when test="$month='12'">
          <xsl:value-of select="'Dec'"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="''" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:value-of select="concat($day, '-' ,$monthname, '-', $year , ' ', $time)" />
  </xsl:template>
</xsl:stylesheet>


Now when you run this report, you will see the following:

Test #NameStatusLast ExecutedExecution Count
1Functional TestsN/A30-Nov-2003 0
46Test 1 for DemoFailed08-May-2015 1
47Nouveau scénario de testNot Run-- 0
2Ability to create new bookFailed14-May-2015 15
3Ability to edit existing bookBlocked08-May-2015 6
4Ability to create new authorFailed12-Jun-2015 10
31New Test Case (Ability to report on books on loan)Passed17-Jul-2015 2
32Test that the system lets you reportNot Run-- 0
5Ability to edit existing authorPassed01-Jun-2015 3
6Ability to reassign book to different authorPassed30-Nov-2003 1
38Create New Book - AutomatedNot Run-- 0
43Mobile Test for DemoNot Run-- 0
39Performance TestsN/A01-Jun-2015 0
72Ability to edit existing author - copyPassed01-Jun-2015 3
40Verify load times of home pageNot Run-- 0
7Regression TestsN/A30-Nov-2003 0
8Book managementPassed30-Nov-2003 1
9Author managementPassed30-Nov-2003 1
29Rapise New TestsN/A31-Mar-2015 0
30Test Case 1Not Run-- 0
34MS-Paint TestPassed31-Mar-2015 6
48Library Test 1Not Run-- 0
49Sample Windows AppNot Run-- 0
42Conference Web Test 1Not Run-- 0
10Scenario TestsN/A28-May-2015 0
11Exception Scenario TestsN/A28-May-2015 0
12Person loses book and needs to report lossBlocked28-May-2015 1
13Adding new book and author to libraryNot Run-- 0
15Common TestsN/A30-Nov-2003 0
16Open Up Web BrowserPassed30-Nov-2003 0
17Login to ApplicationPassed30-Nov-2003 0
33Tests that you can copy book editionsFailed17-Jul-2015 2
35New Test Case (Additonal Edition Functionality)Not Run-- 0
36New Test Case (Ability to link authors to their contact information)Not Run-- 0
37New Test Case (Ability to associate authors with subjects)Not Run-- 0
41New Test Case (System needs to be able to report on aging)Failed13-May-2015 2
50Tests that we can add new subjects to the systemNot Run-- 0
51New Test Case (Ability to edit existing subjects in the system)Not Run-- 0
Attachments
Article Info
Last Updated: 7/28/2015
Article ID: KB167
# Views: 1000
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.