Redian新闻
>
java 写unit test 给clover 真就是农民阿
avatar
java 写unit test 给clover 真就是农民阿# Java - 爪哇娇娃
c*n
1
暴无聊,看到coverage 到90% 以下了,
看report, 红条的代码,一条条照抄加到test code 里面去,
我才领会到"码农/硅工“这词的含义
avatar
m*t
2
Coverage reports are supposed to be reviewed by human beings.
Core code has to have 100% coverage (maybe excluding crazy exceptions).
Getters and setters don't need to be covered at all.

【在 c******n 的大作中提到】
: 暴无聊,看到coverage 到90% 以下了,
: 看report, 红条的代码,一条条照抄加到test code 里面去,
: 我才领会到"码农/硅工“这词的含义

avatar
s*e
3
The funny part of clover is that it is too damn "clever"
it will think that you miss the coverage if you have code like below but
only test the "if" branch (coverage)
if (true)
{
doSomething();
}
It will be complaining that you miss testing "if(false)" even you want to do
nothing.
avatar
m*t
4
Are you sure? I thought if (true) would always get optimized away these
days.

do

【在 s******e 的大作中提到】
: The funny part of clover is that it is too damn "clever"
: it will think that you miss the coverage if you have code like below but
: only test the "if" branch (coverage)
: if (true)
: {
: doSomething();
: }
: It will be complaining that you miss testing "if(false)" even you want to do
: nothing.

avatar
s*e
5
I really did not mean the literal value "true" when I said if(true). I meant
something evaluated to be true. If your question is about the evaluated
expression. Yes I am sure.
avatar
Q*g
6
nothing special here. line coverage vs branch coverage

do

【在 s******e 的大作中提到】
: The funny part of clover is that it is too damn "clever"
: it will think that you miss the coverage if you have code like below but
: only test the "if" branch (coverage)
: if (true)
: {
: doSomething();
: }
: It will be complaining that you miss testing "if(false)" even you want to do
: nothing.

avatar
s*e
7
well you will feel it "very special" if you have a team policy of 100%
coverage, and for the case where you need to mockito many, many things to
test the nonexisting branch.
avatar
m*t
8

Well... no... if it's a branch that really could go either way, then you
gotta
test both. I agree that it can be painful, compounded by a 100% coverage
policy, but it doesn't sound reasonable to blame the tool for reporting it.

【在 s******e 的大作中提到】
: well you will feel it "very special" if you have a team policy of 100%
: coverage, and for the case where you need to mockito many, many things to
: test the nonexisting branch.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。