c******n 发帖数: 4965 | 1 暴无聊,看到coverage 到90% 以下了,
看report, 红条的代码,一条条照抄加到test code 里面去,
我才领会到"码农/硅工“这词的含义 |
m******t 发帖数: 2416 | 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 里面去, : 我才领会到"码农/硅工“这词的含义
|
s******e 发帖数: 493 | 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. |
m******t 发帖数: 2416 | 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.
|
s******e 发帖数: 493 | 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. |
Q**g 发帖数: 183 | 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.
|
s******e 发帖数: 493 | 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. |
m******t 发帖数: 2416 | 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.
|