OpenCover报告分析

OpenCover报告分析

问题描述:

我使用OpenCover计算代码覆盖率,我在xml格式的后续响应中使用了响应。OpenCover报告分析

<CoverageSession xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 


<Modules> 
<Module hash="FD-FE-41-D9-AB-19-E3-F2-D4-3A-E6-27-3D-30-A5-CC-E1-13-AC-C1"> 
    <FullName>D:\DEMO\TestProject\bin\Debug\TestProject.dll</FullName> 
    <ModuleName>TestProject</ModuleName> 
    <Files> 
    <File uid="1" fullPath="D:\Demo\TestProject\MathFunctionsTest.cs" /> 
    </Files> 
    <Classes> 
    <Class> 
     <FullName>&lt;Module&gt;</FullName> 
     <Methods /> 
    </Class> 
    <Class> 
     <FullName>TestProject.MathFunctionsTest</FullName> 
     <Methods> 
     <Method visited="false" cyclomaticComplexity="1" sequenceCoverage="0" branchCoverage="0" isConstructor="false" isStatic="false" isGetter="true" isSetter="false"> 
      <MetadataToken>100663297</MetadataToken> 
      <Name>Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestProject.MathFunctionsTest::get_TestContext()</Name> 
      <FileRef uid="1" /> 
      <SequencePoints> 
      <SequencePoint vc="0" uspid="1" ordinal="0" offset="0" sl="27" sc="13" el="27" ec="14" /> 
      <SequencePoint vc="0" uspid="2" ordinal="1" offset="1" sl="28" sc="17" el="28" ec="44" /> 
      <SequencePoint vc="0" uspid="3" ordinal="2" offset="10" sl="29" sc="13" el="29" ec="14" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="0" uspid="1" ordinal="0" offset="0" sl="27" sc="13" el="27" ec="14" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="true"> 
      <MetadataToken>100663298</MetadataToken> 
      <Name>System.Void TestProject.MathFunctionsTest::set_TestContext(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext)</Name> 
      <FileRef uid="1" /> 
      <SequencePoints> 
      <SequencePoint vc="5" uspid="4" ordinal="0" offset="0" sl="31" sc="13" el="31" ec="14" /> 
      <SequencePoint vc="5" uspid="5" ordinal="1" offset="1" sl="32" sc="17" el="32" ec="45" /> 
      <SequencePoint vc="5" uspid="6" ordinal="2" offset="8" sl="33" sc="13" el="33" ec="14" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="5" uspid="4" ordinal="0" offset="0" sl="31" sc="13" el="31" ec="14" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663299</MetadataToken> 
      <Name>System.Void TestProject.MathFunctionsTest::MathFunctionsConstructorTest()</Name> 
      <FileRef uid="1" /> 
      <SequencePoints> 
      <SequencePoint vc="1" uspid="7" ordinal="0" offset="0" sl="72" sc="9" el="72" ec="10" /> 
      <SequencePoint vc="1" uspid="8" ordinal="1" offset="1" sl="73" sc="13" el="73" ec="56" /> 
      <SequencePoint vc="1" uspid="9" ordinal="2" offset="7" sl="75" sc="9" el="75" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="1" uspid="7" ordinal="0" offset="0" sl="72" sc="9" el="72" ec="10" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663300</MetadataToken> 
      <Name>System.Void TestProject.MathFunctionsTest::AddTest()</Name> 
      <FileRef uid="1" /> 
      <SequencePoints> 
      <SequencePoint vc="1" uspid="10" ordinal="0" offset="0" sl="82" sc="9" el="82" ec="10" /> 
      <SequencePoint vc="1" uspid="11" ordinal="1" offset="1" sl="83" sc="13" el="83" ec="56" /> 
      <SequencePoint vc="1" uspid="12" ordinal="2" offset="7" sl="84" sc="13" el="84" ec="27" /> 
      <SequencePoint vc="1" uspid="13" ordinal="3" offset="17" sl="85" sc="13" el="85" ec="27" /> 
      <SequencePoint vc="1" uspid="14" ordinal="4" offset="27" sl="86" sc="13" el="86" ec="34" /> 
      <SequencePoint vc="1" uspid="15" ordinal="5" offset="37" sl="88" sc="13" el="88" ec="39" /> 
      <SequencePoint vc="1" uspid="16" ordinal="6" offset="47" sl="89" sc="13" el="89" ec="47" /> 
      <SequencePoint vc="1" uspid="17" ordinal="7" offset="56" sl="91" sc="9" el="91" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="1" uspid="10" ordinal="0" offset="0" sl="82" sc="9" el="82" ec="10" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663301</MetadataToken> 
      <Name>System.Void TestProject.MathFunctionsTest::DivideTest()</Name> 
      <FileRef uid="1" /> 
      <SequencePoints> 
      <SequencePoint vc="1" uspid="18" ordinal="0" offset="0" sl="98" sc="9" el="98" ec="10" /> 
      <SequencePoint vc="1" uspid="19" ordinal="1" offset="1" sl="99" sc="13" el="99" ec="56" /> 
      <SequencePoint vc="1" uspid="20" ordinal="2" offset="7" sl="100" sc="13" el="100" ec="28" /> 
      <SequencePoint vc="1" uspid="21" ordinal="3" offset="17" sl="101" sc="13" el="101" ec="28" /> 
      <SequencePoint vc="1" uspid="22" ordinal="4" offset="27" sl="102" sc="13" el="102" ec="34" /> 
      <SequencePoint vc="1" uspid="23" ordinal="5" offset="37" sl="104" sc="13" el="104" ec="42" /> 
      <SequencePoint vc="1" uspid="24" ordinal="6" offset="47" sl="105" sc="13" el="105" ec="47" /> 
      <SequencePoint vc="1" uspid="25" ordinal="7" offset="56" sl="107" sc="9" el="107" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="1" uspid="18" ordinal="0" offset="0" sl="98" sc="9" el="98" ec="10" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663302</MetadataToken> 
      <Name>System.Void TestProject.MathFunctionsTest::MultiplyTest()</Name> 
      <FileRef uid="1" /> 
      <SequencePoints> 
      <SequencePoint vc="1" uspid="26" ordinal="0" offset="0" sl="114" sc="9" el="114" ec="10" /> 
      <SequencePoint vc="1" uspid="27" ordinal="1" offset="1" sl="115" sc="13" el="115" ec="56" /> 
      <SequencePoint vc="1" uspid="28" ordinal="2" offset="7" sl="116" sc="13" el="116" ec="27" /> 
      <SequencePoint vc="1" uspid="29" ordinal="3" offset="17" sl="117" sc="13" el="117" ec="27" /> 
      <SequencePoint vc="1" uspid="30" ordinal="4" offset="27" sl="118" sc="13" el="118" ec="34" /> 
      <SequencePoint vc="1" uspid="31" ordinal="5" offset="37" sl="120" sc="13" el="120" ec="44" /> 
      <SequencePoint vc="1" uspid="32" ordinal="6" offset="47" sl="121" sc="13" el="121" ec="47" /> 
      <SequencePoint vc="1" uspid="33" ordinal="7" offset="56" sl="123" sc="9" el="123" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="1" uspid="26" ordinal="0" offset="0" sl="114" sc="9" el="114" ec="10" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663303</MetadataToken> 
      <Name>System.Void TestProject.MathFunctionsTest::SubtractTest()</Name> 
      <FileRef uid="1" /> 
      <SequencePoints> 
      <SequencePoint vc="1" uspid="34" ordinal="0" offset="0" sl="130" sc="9" el="130" ec="10" /> 
      <SequencePoint vc="1" uspid="35" ordinal="1" offset="1" sl="131" sc="13" el="131" ec="56" /> 
      <SequencePoint vc="1" uspid="36" ordinal="2" offset="7" sl="132" sc="13" el="132" ec="27" /> 
      <SequencePoint vc="1" uspid="37" ordinal="3" offset="17" sl="133" sc="13" el="133" ec="27" /> 
      <SequencePoint vc="1" uspid="38" ordinal="4" offset="27" sl="134" sc="13" el="134" ec="34" /> 
      <SequencePoint vc="1" uspid="39" ordinal="5" offset="37" sl="136" sc="13" el="136" ec="44" /> 
      <SequencePoint vc="1" uspid="40" ordinal="6" offset="47" sl="137" sc="13" el="137" ec="47" /> 
      <SequencePoint vc="1" uspid="41" ordinal="7" offset="56" sl="139" sc="9" el="139" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="1" uspid="34" ordinal="0" offset="0" sl="130" sc="9" el="130" ec="10" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="0" branchCoverage="0" isConstructor="true" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663304</MetadataToken> 
      <Name>System.Void TestProject.MathFunctionsTest::.ctor()</Name> 
      <SequencePoints /> 
      <BranchPoints /> 
      <MethodPoint vc="5" uspid="42" ordinal="0" offset="0" /> 
     </Method> 
     </Methods> 
    </Class> 
    </Classes> 
</Module> 
<Module hash="CE-A4-EA-1B-A3-A3-41-FC-95-6A-47-ED-DB-FB-8A-39-10-3B-39-6D"> 
    <FullName>d:\demo\testproject\bin\debug\POC.exe</FullName> 
    <ModuleName>POC</ModuleName> 
    <Files> 
    <File uid="3" fullPath="D:\Demo\POC\Program.cs" /> 
    </Files> 
    <Classes> 
    <Class> 
     <FullName>&lt;Module&gt;</FullName> 
     <Methods /> 
    </Class> 
    <Class> 
     <FullName>POC.Program</FullName> 
     <Methods> 
     <Method visited="false" cyclomaticComplexity="1" sequenceCoverage="0" branchCoverage="0" isConstructor="false" isStatic="true" isGetter="false" isSetter="false"> 
      <MetadataToken>100663297</MetadataToken> 
      <Name>System.Void POC.Program::Main(System.String[])</Name> 
      <FileRef uid="3" /> 
      <SequencePoints> 
      <SequencePoint vc="0" uspid="43" ordinal="0" offset="0" sl="11" sc="9" el="11" ec="10" /> 
      <SequencePoint vc="0" uspid="44" ordinal="1" offset="1" sl="13" sc="13" el="13" ec="67" /> 
      <SequencePoint vc="0" uspid="45" ordinal="2" offset="12" sl="14" sc="13" el="14" ec="55" /> 
      <SequencePoint vc="0" uspid="46" ordinal="3" offset="24" sl="15" sc="13" el="15" ec="55" /> 
      <SequencePoint vc="0" uspid="47" ordinal="4" offset="36" sl="16" sc="13" el="16" ec="53" /> 
      <SequencePoint vc="0" uspid="48" ordinal="5" offset="42" sl="17" sc="13" el="17" ec="59" /> 
      <SequencePoint vc="0" uspid="49" ordinal="6" offset="71" sl="18" sc="13" el="18" ec="64" /> 
      <SequencePoint vc="0" uspid="50" ordinal="7" offset="100" sl="19" sc="13" el="19" ec="64" /> 
      <SequencePoint vc="0" uspid="51" ordinal="8" offset="129" sl="20" sc="13" el="20" ec="62" /> 
      <SequencePoint vc="0" uspid="52" ordinal="9" offset="158" sl="21" sc="13" el="21" ec="66" /> 
      <SequencePoint vc="0" uspid="53" ordinal="10" offset="180" sl="22" sc="13" el="22" ec="42" /> 
      <SequencePoint vc="0" uspid="54" ordinal="11" offset="191" sl="23" sc="13" el="23" ec="32" /> 
      <SequencePoint vc="0" uspid="55" ordinal="12" offset="197" sl="24" sc="9" el="24" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="0" uspid="43" ordinal="0" offset="0" sl="11" sc="9" el="11" ec="10" /> 
     </Method> 
     <Method visited="false" cyclomaticComplexity="1" sequenceCoverage="0" branchCoverage="0" isConstructor="true" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663298</MetadataToken> 
      <Name>System.Void POC.Program::.ctor()</Name> 
      <SequencePoints /> 
      <BranchPoints /> 
      <MethodPoint vc="0" uspid="56" ordinal="0" offset="0" /> 
     </Method> 
     </Methods> 
    </Class> 
    <Class> 
     <FullName>POC.MathFunctions</FullName> 
     <Methods> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663299</MetadataToken> 
      <Name>System.Double POC.MathFunctions::Add(System.Double,System.Double)</Name> 
      <FileRef uid="3" /> 
      <SequencePoints> 
      <SequencePoint vc="1" uspid="57" ordinal="0" offset="0" sl="32" sc="9" el="32" ec="10" /> 
      <SequencePoint vc="1" uspid="58" ordinal="1" offset="1" sl="33" sc="13" el="33" ec="26" /> 
      <SequencePoint vc="1" uspid="59" ordinal="2" offset="7" sl="34" sc="9" el="34" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="1" uspid="57" ordinal="0" offset="0" sl="32" sc="9" el="32" ec="10" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663300</MetadataToken> 
      <Name>System.Double POC.MathFunctions::Subtract(System.Double,System.Double)</Name> 
      <FileRef uid="3" /> 
      <SequencePoints> 
      <SequencePoint vc="1" uspid="60" ordinal="0" offset="0" sl="37" sc="9" el="37" ec="10" /> 
      <SequencePoint vc="1" uspid="61" ordinal="1" offset="1" sl="38" sc="13" el="38" ec="26" /> 
      <SequencePoint vc="1" uspid="62" ordinal="2" offset="7" sl="39" sc="9" el="39" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="1" uspid="60" ordinal="0" offset="0" sl="37" sc="9" el="37" ec="10" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663301</MetadataToken> 
      <Name>System.Double POC.MathFunctions::Multiply(System.Double,System.Double)</Name> 
      <FileRef uid="3" /> 
      <SequencePoints> 
      <SequencePoint vc="1" uspid="63" ordinal="0" offset="0" sl="42" sc="9" el="42" ec="10" /> 
      <SequencePoint vc="1" uspid="64" ordinal="1" offset="1" sl="43" sc="13" el="43" ec="26" /> 
      <SequencePoint vc="1" uspid="65" ordinal="2" offset="7" sl="44" sc="9" el="44" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="1" uspid="63" ordinal="0" offset="0" sl="42" sc="9" el="42" ec="10" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="100" branchCoverage="100" isConstructor="false" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663302</MetadataToken> 
      <Name>System.Double POC.MathFunctions::Divide(System.Double,System.Double)</Name> 
      <FileRef uid="3" /> 
      <SequencePoints> 
      <SequencePoint vc="1" uspid="66" ordinal="0" offset="0" sl="47" sc="9" el="47" ec="10" /> 
      <SequencePoint vc="1" uspid="67" ordinal="1" offset="1" sl="48" sc="13" el="48" ec="26" /> 
      <SequencePoint vc="1" uspid="68" ordinal="2" offset="7" sl="49" sc="9" el="49" ec="10" /> 
      </SequencePoints> 
      <BranchPoints /> 
      <MethodPoint xsi:type="SequencePoint" vc="1" uspid="66" ordinal="0" offset="0" sl="47" sc="9" el="47" ec="10" /> 
     </Method> 
     <Method visited="true" cyclomaticComplexity="1" sequenceCoverage="0" branchCoverage="0" isConstructor="true" isStatic="false" isGetter="false" isSetter="false"> 
      <MetadataToken>100663303</MetadataToken> 
      <Name>System.Void POC.MathFunctions::.ctor()</Name> 
      <SequencePoints /> 
      <BranchPoints /> 
      <MethodPoint vc="5" uspid="69" ordinal="0" offset="0" /> 
     </Method> 
     </Methods> 
    </Class> 
    </Classes> 
</Module> 

任何一个可以给我解释一下我怎么能计算代码覆盖率,覆盖线和XML等有用信息的数量。

我使用Xslt将其转换为html,我无法使用报表生成器工具来达到此目的。

在此先感谢。

+0

我写我自己的XSL显示组件和文件和其他东西的数量,但我如何显示代码覆盖率%和线所涵盖的这个xsl。 – user1130157 2012-04-20 10:58:27

+4

“xslt”标签中的人不应该知道OpenCover是什么。为了使这个问题对我们有意义,请提供源XML文档的完整(但最小可能)的实例以及转换的确切想要的结果。定义变革必须实施的要求也很好。 – 2012-04-20 12:17:36

+0

[XSL中的OpenCover XML Result in HTML]可能重复(http://*.com/questions/10244816/opencover-xml-result-in-html-by-xsl) – skolima 2012-04-24 06:21:52

一行代码由SequencePoint覆盖。

拜访SequencePoint有VC> 0

所以对于覆盖运行的总覆盖率为

计数(SequencePoint其中VC> 0)* 100 /计数(SequencePoint

你可以然后通过限制每个模块/类型/方法的搜索来优化结果

BranchPointMethodPoint结果可以按同样的方式

看看ReportGenerator:https://github.com/danielpalme/ReportGenerator 有了这个工具,你可以转换为HTML,XML和乳胶的OpenCover报告

也许这可以帮助: Make OpenCover reports available in CruiseControl.NET

+0

我知道关于报告生成器,但我不能直接在我的巡航控制网站上使用html页面,我需要一些方法,我可以在html.so中转换xml。Xsl是唯一的方法来做到这一点。 – user1130157 2012-04-20 14:12:45

+0

自从我使用CruiseControl以来已经有一段时间了,但是我记得我写过一个包含ReportGenerator创建的HTML报告的插件(链接已添加到TOC中)。这不是很困难,但我不记得任何细节。 – Daniel 2012-04-20 18:06:05

+0

我不能使用报告生成器,可以解释每个领域的OpenCover结果XML或从哪里我可以读取这个 – user1130157 2012-04-24 07:26:48