1

我做了一些更改,jmeter-results-report_21.xsl以在 html 报告中显示测试用例名称。直接在浏览器中打开时效果很好,但是当我使用 ant 生成报告时,它会将页面顶部的案例测试名称和上面的 URL 分组。就像 for 没有嵌套一样。

<xsl:for-each select="/testResults/*[not(@tn = preceding::*/@tn)]">
<xsl:variable name="labelCaso" select="@tn" />
<tr><xsl:value-of select="$labelCaso" /></tr>
    <xsl:for-each select="/testResults/*[not(@lb = preceding::*/@lb)] ">
        <xsl:variable name="label" select="@lb"/>
        <xsl:variable name="count" select="count(../*[@lb = current()/@lb] [attribute::tn=$labelCaso])" />
        <xsl:variable name="failureCount" select="count(../*[@lb = current()/@lb][attribute::s='false'][attribute::tn=$labelCaso])" />
        <xsl:variable name="successCount" select="count(../*[@lb = current()/@lb][attribute::s='true'][attribute::tn=$labelCaso])" />
        <xsl:variable name="successPercent" select="$successCount div $count" />
        <xsl:variable name="totalTime" select="sum(../*[@lb = current()/@lb][attribute::tn=$labelCaso]/@t )" />
        <xsl:variable name="averageTime" select="($totalTime div $count)" />
        <xsl:variable name="minTime">
            <xsl:call-template name="min">
                <xsl:with-param name="nodes" select="../*[@lb = current()/@lb][attribute::tn=$labelCaso]/@t" />
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="maxTime">
            <xsl:call-template name="max">
                <xsl:with-param name="nodes" select="../*[@lb = current()/@lb][attribute::tn=$labelCaso]/@t" />
            </xsl:call-template>
        </xsl:variable>
        <tr valign="top">
            <xsl:attribute name="class">
                <xsl:choose>
                    <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
                </xsl:choose>
            </xsl:attribute>

            <td>
                <xsl:value-of select="$label" /> 
            </td>
            <td align="center">
                <xsl:value-of select="$count" />
            </td>
            <td align="center">
                <xsl:value-of select="$failureCount" />
            </td>
            <td align="right">
                <xsl:call-template name="display-percent">
                    <xsl:with-param name="value" select="$successPercent" />
                </xsl:call-template>
            </td>
            <td align="right">
                <xsl:call-template name="display-time">
                    <xsl:with-param name="value" select="$averageTime" />
                </xsl:call-template>
            </td>
            <td align="right">
                <xsl:call-template name="display-time">
                    <xsl:with-param name="value" select="$minTime" />
                </xsl:call-template>
            </td>
            <td align="right">
                <xsl:call-template name="display-time">
                    <xsl:with-param name="value" select="$maxTime" />
                </xsl:call-template>
            </td>
        </tr>
</xsl:for-each> 
</xsl:for-each>
4

0 回答 0