将opencover xml输出转换为ncover xml [英] transform opencover xml output to ncover xml
问题描述
我需要将Opencover Coverage结果导入Jenkins的能力,以便随时间推移获取Coverage趋势数据. 似乎最好的方法是找到一种方法,将opencover xml格式转换为ncover格式,然后使用NCover插件导入结果.是否有现有的xslt可以将opencover转换为ncover,还是可以进行转换的开源工具? 我已经搜索过,却一无所获.
I need the ability to import opencover coverage results in to Jenkins to pull coverage trending data over time. It appears that the best way to do this is going to be finding a way to convert the opencover xml format to ncover format, and then use the NCover plugin to import the results. Is there an existing xslt that will transform opencover to ncover, or an open source tool that will do the conversion? I've searched, and I'm finding nothing.
谢谢
推荐答案
The following XSLT is available on the OpenCover wiki which might get you started.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" standalone="yes"/>
<xsl:template match="/CoverageSession/Modules">
<coverage>
<xsl:for-each select="Module[not(@skippedDueTo)]">
<module name="{ModuleName}">
<xsl:for-each select="Classes/Class">
<xsl:if test="count(Methods/Method) > 0">
<class name="{FullName}">
<xsl:variable name="className" select="FullName" />
<xsl:for-each select="Methods/Method">
<method class="{$className}">
<xsl:for-each select="SequencePoints/SequencePoint">
<seqpnt visitcount="{@vc}" />
</xsl:for-each>
</method>
</xsl:for-each>
</class>
</xsl:if>
</xsl:for-each>
</module>
</xsl:for-each>
</coverage>
</xsl:template>
</xsl:stylesheet>
这篇关于将opencover xml输出转换为ncover xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!