Please enable JavaScript to view this site.

Coverage Validator Help


The Code Exclusion tab allows you to configure blocks of code to be removed from code coverage, using comments in the source code.





Code exclusion


In general the code coverage filters work on discreet elements like file, class and function names.


Code exclusion lets you further control sections of a source file to be excluded by using pragmas (keyword directives) to mark the a region of code.


The pragmas can surround complete classes, functions or just single lines of code.



Using code exclusion


The reason for providing code exclusion is to allow code coverage tests to be setup knowing that a file can reach 100% coverage even if certain lines are not processed.


Such lines may not be processed because they are on a code path that will only be taken during error conditions. See the examples below.


Enable code exclusion pragmas instructionStep check the box to turn the feature on



Multi-line code exclusion


Start Pragma instructionStep enter the keyword that you will use in the code to mark the start of a block to exclude


E.g. CVPragmaMultiLineStart

End Pragma instructionStep enter the keyword that you will use in the code to mark the end of the excluded block


E.g. CVPragmaMultiLineEnd

Now you can exclude a section of code by enclosing code with comments containing these pragmas




Without code exclusion switched on, the for loop below would count towards coverage:




After turning code exclusion on, the pragmas shown here force the loop to be excluded from coverage statistics:





Single line code exclusion


Single Line Pragma instructionStep enter the keyword that you will use in the code


E.g. CVPragmaSingleLineIgnore

Now you can exclude a single line of code by adding a comment to the line containing the pragma CVPragmaSingleLineIgnore




The assert statement in the code below only happens in an error situation, and probably an unrecoverable one at that.


Without using code exclusion, the assertion would count towards incomplete coverage.




After turning code exclusion on and setting up the pragma blow, the assertion line is ignored in the coverage







Instrumentation logging


The logging of DLLs, source files, classes, methods and functions that are not instrumented can help you understand the reason why part of your code isn't getting the coverage information you expect.


Once enabled, and a session has started, you can view a list of items that have not been instrumented via the Tools menu.


Enable instrumentation logging instructionStep check to enable logging once the next session starts



Reset All - Resets all global settings, not just those on the current page.



Reset - Resets the settings on the current page.