休眠升级后代码覆盖率显着下降 - 未覆盖 getter 和 setter - 有什么想法吗?
我们最近将代码库从 2005 版本升级到了最新版本的 hibernate。
因此,我们发现许多软件包中的代码覆盖率显着降低。这些包几乎都是映射到 hibernate 对象的 POJO,区别似乎在于 getter 和 setter 的覆盖范围。这些对象中的大多数都没有直接进行单元测试,因此之前的报道大部分来自于它们在某些集成测试中的使用,导致 hibernate 命中这些 getter 和 setter。
有谁见过类似的事情发生吗? hibernate 填充那些可以解释这一点的对象的方式是否发生了变化?
大多数字段都设置为lazy=false,因此这可能是没有问题的。
我们使用 testng、cobertura 和 jdk 1.6。
We have recently upgraded our code base from a 2005 version to the latest version of hibernate.
As a result of that, we're seeing significantly reduced code coverage in a number of our packages. These packages are almost entirely POJOs mapped to hibernate objects, and the difference seems to be in the coverage of getters and setters. Most of these objects are not directly unit tested, so the previous coverage most have come from their usage in some integration test causing hibernate to hit these getters and setters.
Has anyone seen similar things happening? Has there been a change in the way hibernate populates those objects that could explain that?
Most of the fields are set to lazy=false so that's probably out of question.
We are using testng, cobertura and jdk 1.6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不是专家,但也许最新版本的 hibernate 在类的字段中注入值,而以前的版本使用 getter 和 setter...
你把注释放在哪里?
在字段上
还是在方法上?
I'm not an expert, but maybe the latest version of hibernate inject the values in the fields of your class, while previous version use getters and setters...
Where did you put your annotations?
on fields
or on methods?
是否有人更改了 xml 中的某些内容来更改对字段的访问,例如
或像这样全局更改?
默认情况下,hibernate 的访问权限设置为属性,因此应使用提供的访问器。
Has somebody changed something in the xml to change the access to field, e.g.
or globally like this?
By default hibernate's access is set to property, so that should use accessors where they are provided.