Jacoco maven plugin not recognizing public classes

30 views
Skip to first unread message

pedro...@varitus.com.br

unread,
Oct 17, 2018, 7:22:35 AM10/17/18
to JaCoCo and EclEmma Users
I'm using jacoco coverage report on my java maven project, but it doesn't seem to recognize branchs on public functions

As an example, if i send a file with this function:

public class CobrancaConverter {

public CobrancaEntity convert(NFeCobrancaEntity cobranca, NfePK nfeKey) {
if (cobranca == null) {
return null;
} else {
DuplicatasConverter duplicatasConverter = new DuplicatasConverter();
CobrancaEntity entity = new CobrancaEntity();
entity.setY03Nfat(cobranca.getNfat());
entity.setY04Vorig(cobranca.getvOrig());
entity.setY05Vdesc(cobranca.getvDesc());
entity.setY06Vliq(cobranca.getvLiq());
entity.setKey(nfeKey);
List<CobrancaDuplicataEntity> duplicatas = duplicatasConverter.convert(cobranca.getDuplicatas(), nfeKey);
entity.setDuplicatas(duplicatas);
return entity;
}
}
}

Jacoco doesn't recognize the "if" as a branch and doesn't count it towards the covered branchs percentage, but if i create a public function calling a private function, like this, it works.


public class CobrancaConverter {
public CobrancaEntity converter(NFeCobrancaEntity cobranca, NfePK nfeKey){
return convert(cobranca, nfeKey);
}

private CobrancaEntity convert(NFeCobrancaEntity cobranca, NfePK nfeKey) {
if (cobranca == null) {
return null;
} else {
DuplicatasConverter duplicatasConverter = new DuplicatasConverter();
CobrancaEntity entity = new CobrancaEntity();
entity.setY03Nfat(cobranca.getNfat());
entity.setY04Vorig(cobranca.getvOrig());
entity.setY05Vdesc(cobranca.getvDesc());
entity.setY06Vliq(cobranca.getvLiq());
entity.setKey(nfeKey);
List<CobrancaDuplicataEntity> duplicatas = duplicatasConverter.convert(cobranca.getDuplicatas(), nfeKey);
entity.setDuplicatas(duplicatas);
return entity;
}
}
}

Shouldn't Jacoco recognize both cases? Am i doing something wrong, is this expected or this is a bug i should report?

Evgeny Mandrikov

unread,
Oct 17, 2018, 9:57:43 AM10/17/18
to JaCoCo and EclEmma Users
On Wednesday, October 17, 2018 at 1:22:35 PM UTC+2, pedro...@varitus.com.br wrote:

Am i doing something wrong, is this expected or this is a bug i should report?


Yes - you're doing something wrong, because there is no difference between private and public methods for JaCoCo.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages