I found a way to do it.
I visit every line of a ClassCoverage checking the TotalCount of the
BranchCounter, if it is greater than 0, then there is a branch in that line. To
check if it is visited, I check if the CoveredCount is different than 0.
Here is the snippet for the code (keep in mind that it is an experimental code):
for (IClassCoverage classCoverage : coverageBuilder.getClasses())
{
boolean[] branchProbes = new
boolean[classCoverage.getBranchCounter().getTotalCount()];
int currentBranchIndex = 0;
if (branchProbes.length != 0)
{
for (int x = 0; x <
classCoverage.getLastLine(); x++)
{
ILine line = classCoverage.getLine(x);
if (line.getBranchCounter().getTotalCount()
!= 0)
{
branchProbes[currentBranchIndex++] =
line.getBranchCounter().getCoveredCount() != 0;
}
}
}
I'm sharing in case someone needs it in the future.
Em segunda-feira, 4 de dezembro de 2017 17:45:54 UTC-2, [email protected]
escreveu:
> Hello! I'm trying to get some information about a coverage run.
> I have statements probes array (ExecutionData), which I collect using an
> ExecutionDataVisitor, collecting statements probes array for each test run
> (using a custom JUnit listener).
>
> Now I need to figure out which method/branch from each executed class have
> been executed.
>
> I managed to retrieve numbers about covered methods/branches/statements by
> analyzing the ExecutionData using a CoverageBuilder. I found also that I can
> check the name of each method executed and with this I can generate my own
> list of which of all methods have been executed. Now I need to do the same
> with branches, but I didn't figure any way to do this. The ideal would be an
> array containing all possible executable branches and those that were
> executed, marked with a flag (same mechanism as ExecutionData).
>
> Anyone can provide me some light?
> Thanks in advance!
--
You received this message because you are subscribed to the Google Groups
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/51798144-21e5-458f-b1ec-2fb39f107529%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.