gpt4 book ai didi

testing - 是否仍然没有使用 cobertura-maven-plugin 忽略 setter/getter(其他琐碎的方法)的解决方案?

转载 作者:行者123 更新时间:2023-11-28 19:40:22 24 4
gpt4 key购买 nike

有人找到忽略琐碎方法的好解决方案了吗?
使用一些自动化测试,如 Unitils这不是一个真正的选择,因为如果只测试 getter/setter,代码覆盖率不应上升!

使用 cobertrua-maven-plugin 版本 2.5.1:
-) 忽略方法不起作用 <ignore>com.company.*.set*</ignore>
-) 有没有人尝试包含像 http://sourceforge.net/tracker/index.php?func=detail&aid=3010530&group_id=130558&atid=720017 这样的补丁进入 maven 插件?
-) 有人使用不同的(更好的?)测试插件吗?

一般忽略每个 get/set/is* 方法也不是真正的好方法,因为这些模式可以用于其他方法,但 simle getter/setter。此外,应该很容易猜出琐碎的 getters/setters/constructors。

我知道这个问题:Ignore methods in class. cobertura maven plugin但由于它没有得到任何相关答案,我想我再试一次。

最佳答案

从 Cobertura 2.0 开始,有一个开关可以排除琐碎的方法:

[Cobertura Changelog] New --ignoreTrivial switch that tells Cobertura to ignore the following in the coverage report: Getter methods that simply read a class field; Setter methods that set a class field; Constructors that only set class fields and call a super class constructor.

cobertura-maven-plugin 使用 Cobertura 2.x 自版本 2.6(参见 release notes)。但是我还没有找到将开关传递给 Maven 插件配置的方法。


尽管此功能的状态似乎有些困惑(请参阅 Jira issue),但该标志似乎适用于以下配置:

<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<instrumentation>
<ignoreTrivial>true</ignoreTrivial>
</instrumentation>
</configuration>

关于testing - 是否仍然没有使用 cobertura-maven-plugin 忽略 setter/getter(其他琐碎的方法)的解决方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9261731/

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