Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Branch coverage for expressions in OpenCover

Does branch coverage work on the following statement?

I expected a red indicator because the first expression only has tests where it is false and not true.

tax.Voided = P_tax.Amount == 1012312870000.42M || P_tax.Amount < 0.00M;

The first expression is always false and the second is sometimes true: ReportGenerator snapshot

like image 680
Ryan Andres Avatar asked Dec 12 '22 09:12

Ryan Andres


1 Answers

Do not confuse reporting by ReportGenerator with OpenCover XML output; though until the OpenCover starts working on their own reporting visuals ReportGenerator is currently the best you will find for now.

Your problem here is the reporting tool does not report (red/green) coverage based on branch coverage only on sequence coverage.

You will need to look at the overview of branch coverage aginst the method (that is summarised at the top of the report) - for more detail view you should look at the XML report data for the method and perhaps compare that against the IL (where OpenCover gets the coverage information from).

Note: OpenCover does not know what language you wrote the code in all it sees is the IL that has been produced.

like image 123
Shaun Wilde Avatar answered Jan 13 '23 11:01

Shaun Wilde