- -6ren">
gpt4 book ai didi

java - EclEmma for Eclipse 可以通过测试显示代码覆盖率吗?

转载 作者:行者123 更新时间:2023-12-01 17:15:54 24 4
gpt4 key购买 nike

所以我在 Eclipse 中使用 EclEmma 来生成 XML 覆盖率报告。看起来像这样:

<?xml version="1.0" encoding="UTF-8" standalone="true"?>

<!DOCTYPE report SYSTEM "report.dtd" PUBLIC "-//JACOCO//DTD Report 1.1//EN">

-<report name="mainTest (1) (Apr 23, 2020 3:48:01 PM)">


-<group name="covTest2">


-<group name="src">


-<package name="covTest2">


-<class name="covTest2/main" sourcefilename="main.java">


-<method name="<init>" line="3" desc="()V">

<counter covered="0" missed="3" type="INSTRUCTION"/>

<counter covered="0" missed="1" type="LINE"/>

<counter covered="0" missed="1" type="COMPLEXITY"/>

<counter covered="0" missed="1" type="METHOD"/>

</method>


-<method name="main" line="5" desc="([Ljava/lang/String;)V">

<counter covered="0" missed="11" type="INSTRUCTION"/>

<counter covered="0" missed="3" type="LINE"/>

<counter covered="0" missed="1" type="COMPLEXITY"/>

<counter covered="0" missed="1" type="METHOD"/>

</method>

<counter covered="0" missed="14" type="INSTRUCTION"/>

<counter covered="0" missed="4" type="LINE"/>

<counter covered="0" missed="2" type="COMPLEXITY"/>

<counter covered="0" missed="2" type="METHOD"/>

<counter covered="0" missed="1" type="CLASS"/>

</class>


-<class name="covTest2/calc" sourcefilename="calc.java">


-<method name="<init>" line="3" desc="()V">

<counter covered="3" missed="0" type="INSTRUCTION"/>

<counter covered="1" missed="0" type="LINE"/>

<counter covered="1" missed="0" type="COMPLEXITY"/>

<counter covered="1" missed="0" type="METHOD"/>

</method>


-<method name="sum" line="5" desc="(II)I">

<counter covered="4" missed="0" type="INSTRUCTION"/>

<counter covered="1" missed="0" type="LINE"/>

<counter covered="1" missed="0" type="COMPLEXITY"/>

<counter covered="1" missed="0" type="METHOD"/>

</method>

<counter covered="7" missed="0" type="INSTRUCTION"/>

<counter covered="2" missed="0" type="LINE"/>

<counter covered="2" missed="0" type="COMPLEXITY"/>

<counter covered="2" missed="0" type="METHOD"/>

<counter covered="1" missed="0" type="CLASS"/>

</class>


-<sourcefile name="main.java">

<line cb="0" mb="0" ci="0" mi="3" nr="3"/>

<line cb="0" mb="0" ci="0" mi="4" nr="5"/>

<line cb="0" mb="0" ci="0" mi="6" nr="6"/>

<line cb="0" mb="0" ci="0" mi="1" nr="7"/>

<counter covered="0" missed="14" type="INSTRUCTION"/>

<counter covered="0" missed="4" type="LINE"/>

<counter covered="0" missed="2" type="COMPLEXITY"/>

<counter covered="0" missed="2" type="METHOD"/>

<counter covered="0" missed="1" type="CLASS"/>

</sourcefile>


-<sourcefile name="calc.java">

<line cb="0" mb="0" ci="3" mi="0" nr="3"/>

<line cb="0" mb="0" ci="4" mi="0" nr="5"/>

<counter covered="7" missed="0" type="INSTRUCTION"/>

<counter covered="2" missed="0" type="LINE"/>

<counter covered="2" missed="0" type="COMPLEXITY"/>

<counter covered="2" missed="0" type="METHOD"/>

<counter covered="1" missed="0" type="CLASS"/>

</sourcefile>

<counter covered="7" missed="14" type="INSTRUCTION"/>

<counter covered="2" missed="4" type="LINE"/>

<counter covered="2" missed="2" type="COMPLEXITY"/>

<counter covered="2" missed="2" type="METHOD"/>

<counter covered="1" missed="1" type="CLASS"/>

</package>


-<package name="TestCase">


-<class name="TestCase/mainTest" sourcefilename="mainTest.java">


-<method name="<init>" line="9" desc="()V">

<counter covered="0" missed="3" type="INSTRUCTION"/>

<counter covered="0" missed="1" type="LINE"/>

<counter covered="0" missed="1" type="COMPLEXITY"/>

<counter covered="0" missed="1" type="METHOD"/>

</method>


-<method name="test" line="13" desc="()V">

<counter covered="0" missed="11" type="INSTRUCTION"/>

<counter covered="0" missed="3" type="LINE"/>

<counter covered="0" missed="1" type="COMPLEXITY"/>

<counter covered="0" missed="1" type="METHOD"/>

</method>

<counter covered="0" missed="14" type="INSTRUCTION"/>

<counter covered="0" missed="4" type="LINE"/>

<counter covered="0" missed="2" type="COMPLEXITY"/>

<counter covered="0" missed="2" type="METHOD"/>

<counter covered="0" missed="1" type="CLASS"/>

</class>


-<sourcefile name="mainTest.java">

<line cb="0" mb="0" ci="0" mi="3" nr="9"/>

<line cb="0" mb="0" ci="0" mi="4" nr="13"/>

<line cb="0" mb="0" ci="0" mi="6" nr="14"/>

<line cb="0" mb="0" ci="0" mi="1" nr="16"/>

<counter covered="0" missed="14" type="INSTRUCTION"/>

<counter covered="0" missed="4" type="LINE"/>

<counter covered="0" missed="2" type="COMPLEXITY"/>

<counter covered="0" missed="2" type="METHOD"/>

<counter covered="0" missed="1" type="CLASS"/>

</sourcefile>

<counter covered="0" missed="14" type="INSTRUCTION"/>

<counter covered="0" missed="4" type="LINE"/>

<counter covered="0" missed="2" type="COMPLEXITY"/>

<counter covered="0" missed="2" type="METHOD"/>

<counter covered="0" missed="1" type="CLASS"/>

</package>

<counter covered="7" missed="28" type="INSTRUCTION"/>

<counter covered="2" missed="8" type="LINE"/>

<counter covered="2" missed="4" type="COMPLEXITY"/>

<counter covered="2" missed="4" type="METHOD"/>

<counter covered="1" missed="2" type="CLASS"/>

</group>

<counter covered="7" missed="28" type="INSTRUCTION"/>

<counter covered="2" missed="8" type="LINE"/>

<counter covered="2" missed="4" type="COMPLEXITY"/>

<counter covered="2" missed="4" type="METHOD"/>

<counter covered="1" missed="2" type="CLASS"/>

</group>

<counter covered="7" missed="28" type="INSTRUCTION"/>

<counter covered="2" missed="8" type="LINE"/>

<counter covered="2" missed="4" type="COMPLEXITY"/>

<counter covered="2" missed="4" type="METHOD"/>

<counter covered="1" missed="2" type="CLASS"/>

</report>

在此文件中,它显示了一个测试“mainTest”我想知道的是女巫文件“mainTest”覆盖以及测试“mainTest”覆盖的这些文件的百分比。如果 ECLemma 不起作用,欢迎提供其他可以实现此目的的工具的提示:)

最佳答案

您可以使用“includes”参数来指定报告中需要哪些类。请参阅此处的文档:

https://www.eclemma.org/jacoco/trunk/doc/report-mojo.html

还有许多其他可用的代码覆盖工具,选择您想要包含的测试将是一个常见的选择。此处提供示例列表:

https://en.wikipedia.org/wiki/Java_code_coverage_tools

关于java - EclEmma for Eclipse 可以通过测试显示代码覆盖率吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61389403/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com