Question

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

Was it helpful?

Solution

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.

OTHER TIPS

If your coverage tool doesn't understand that you can have several interesting "coverable" entities within a line, you will likely get a report that your line is covered if any coverage entity in that line is covered.

Tools that instrument class files are, AFAIK, limited in this way because the class files on only contain information relating class code to source lines, not partial lines.

Our Java Test Coverage tool (and other members of our test coverage tool famility) don't instrument the class code files. Rather, they instrument the source code, and track the partial line information (starting line/column, ending line/column) accurately.

Our tool wouldn't have any trouble showing the coverage on the individual parts of the statement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top