transform opencover xml output to ncover xml

微笑、不失礼 提交于 2020-01-04 04:19:06

问题


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.

thanks


回答1:


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) &gt; 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>


来源:https://stackoverflow.com/questions/14592274/transform-opencover-xml-output-to-ncover-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!