我正在尝试在 TeamCity 5.0 中正确生成 PartCover 报告。当我单击构建详细信息中的“代码覆盖率”选项卡时,报告为空。
我正在使用 sln2008 构建代理,我的 PartCoverage 设置如下:
包括模式:
[*]*
报告 XSLT:
C:\Program Files\PartCover .NET 2.3\xslt\Report By Assembly.xslt=>ByAssembly.html
C:\Program Files\PartCover .NET 2.3\xslt\Report By Class.xslt=>ByClass.html
如果您能够描述如何将这些报告(或仅重要部分)包含在 TeamCity 发送的成功/失败构建的电子邮件中,则可获得加分。如果可能的话,我想继续使用 sln2008 构建代理,而不是其他构建代理。
我对 PartCover 报告也有同样的问题。因此,我一直在努力使其正常工作,但我刚刚发现问题出在 PartCover 发行版附带的两个 XSLT 文件上。
我修复了这些文件,现在一切正常:
大会报告
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="cov0style" select="'background:#E79090;text-align:right;'"/>
<xsl:variable name="cov20style" select="'background:#D79797;text-align:right;'"/>
<xsl:variable name="cov40style" select="'background:#D7A0A0;text-align:right;'"/>
<xsl:variable name="cov60style" select="'background:#C7A7A7;text-align:right;'"/>
<xsl:variable name="cov80style" select="'background:#C0B0B0;text-align:right;'"/>
<xsl:variable name="cov100style" select="'background:#D7D7D7;text-align:right;'"/>
<table style="border-collapse: collapse;">
<tr style="font-weight:bold; background:whitesmoke;">
<td colspan="2">Coverage by assembly</td>
</tr>
<xsl:variable name="asms" select="/PartCoverReport/Assembly"/>
<xsl:for-each select="$asms">
<xsl:variable name="current-asm-node" select="."/>
<tr>
<xsl:element name="td">
<xsl:attribute name="style">background:ghostwhite; padding: 5px 30px 5px 5px;</xsl:attribute>
<xsl:value-of select="$current-asm-node/@name"/>
</xsl:element>
<xsl:variable name="codeSize" select="sum(/PartCoverReport/Type[@asmref=$current-asm-node/@id]/Method/pt/@len)+0"/>
<xsl:variable name="coveredCodeSize" select="sum(/PartCoverReport/Type[@asmref=$current-asm-node/@id]/Method/pt[@visit>0]/@len)+0"/>
<xsl:element name="td">
<xsl:if test="$codeSize=0">
<xsl:attribute name="style">
<xsl:value-of select="$cov0style"/>
</xsl:attribute>
0%
</xsl:if>
<xsl:if test="$codeSize > 0">
<xsl:variable name="coverage" select="ceiling(100 * $coveredCodeSize div $codeSize)"/>
<xsl:if test="$coverage >= 0 and $coverage < 20">
<xsl:attribute name="style">
<xsl:value-of select="$cov20style"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$coverage >= 20 and $coverage < 40">
<xsl:attribute name="style">
<xsl:value-of select="$cov40style"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$coverage >= 40 and $coverage < 60">
<xsl:attribute name="style">
<xsl:value-of select="$cov60style"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$coverage >= 60 and $coverage < 80">
<xsl:attribute name="style">
<xsl:value-of select="$cov80style"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$coverage >= 80">
<xsl:attribute name="style">
<xsl:value-of select="$cov100style"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$coverage"/>%
</xsl:if>
</xsl:element>
</tr>
</xsl:for-each>
</table>
按班级报告
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt">
<xsl:output method="html" indent="no"/>
<xsl:template match="/">
<xsl:variable name="cov0style" select="'background:#FF4040;text-align:right;'"/>
<xsl:variable name="cov20style" select="'background:#F06060;text-align:right;'"/>
<xsl:variable name="cov40style" select="'background:#E78080;text-align:right;'"/>
<xsl:variable name="cov60style" select="'background:#E0A0A0;text-align:right;'"/>
<xsl:variable name="cov80style" select="'background:#D7B0B0;text-align:right;'"/>
<xsl:variable name="cov100style" select="'background:#E0E0E0;text-align:right;'"/>
<table style="border-collapse: collapse;">
<tr style="font-weight:bold; background:whitesmoke;"><td colspan="2">Coverage by class</td></tr>
<xsl:for-each select="/PartCoverReport/Type">
<tr>
<xsl:element name="td">
<xsl:attribute name="style">background:ghostwhite; padding: 5px 30px 5px 5px;</xsl:attribute>
<xsl:value-of select="@name"/>
</xsl:element>
<xsl:variable name="codeSize" select="sum(./Method/pt/@len)+0"/>
<xsl:variable name="coveredCodeSize" select="sum(./Method/pt[@visit>0]/@len)+0"/>
<xsl:element name="td">
<xsl:if test="$codeSize=0">
<xsl:attribute name="style"><xsl:value-of select="$cov0style"/></xsl:attribute>
0%
</xsl:if>
<xsl:if test="$codeSize > 0">
<xsl:variable name="coverage" select="ceiling(100 * $coveredCodeSize div $codeSize)"/>
<xsl:if test="$coverage >= 0 and $coverage < 20"><xsl:attribute name="style"><xsl:value-of select="$cov20style"/></xsl:attribute></xsl:if>
<xsl:if test="$coverage >= 20 and $coverage < 40"><xsl:attribute name="style"><xsl:value-of select="$cov40style"/></xsl:attribute></xsl:if>
<xsl:if test="$coverage >= 40 and $coverage < 60"><xsl:attribute name="style"><xsl:value-of select="$cov60style"/></xsl:attribute></xsl:if>
<xsl:if test="$coverage >= 60 and $coverage < 80"><xsl:attribute name="style"><xsl:value-of select="$cov80style"/></xsl:attribute></xsl:if>
<xsl:if test="$coverage >= 80"><xsl:attribute name="style"><xsl:value-of select="$cov100style"/></xsl:attribute></xsl:if>
<xsl:value-of select="$coverage"/>%
</xsl:if>
</xsl:element>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
希望这个对你有帮助。此外,欢迎有关此文件的任何反馈,以便我们可以向社区提供正确的文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)