Documentation

Documentation
V5 Documentation

Code Coverage Suppression

NCrunch allows you to use inline comments to control which lines of code should be analysed for test coverage and performance metrics.

These inline comments are language agnostic and can be placed anywhere in your source code. NCrunch will immediately detect them and avoid instrumenting or processing any code that exists within the regions specified by the comments.

This can be very useful in the following situations:

  • If you wish to hide irrelevant uncovered lines of code from the NCrunch Metrics View
  • If you wish to improve the performance of a selective region of code under test. As NCrunch's instrumentation adds weight to the code, turning it off for frequently executed lines can improve test performance.
  • If you are experiencing a problem caused by NCrunch's instrumentation. Turning off the instrumentation for certain regions of code may allow you to continue working with NCrunch without needing to disable the Instrument output assembly project-level configuration option.

NCrunch recognises 3 different types of coverage suppression comments:

  • //ncrunch: no coverage start - Marks the beginning of a block of code with code coverage suppression.
  • //ncrunch: no coverage end - Marks the end of a block of code with code coverage suppression.
  • //ncrunch: no coverage - Marks an individual line of code for code coverage suppression (place at the end of the line).

When working with a language other than C#, simply replace the '//' comment syntax with a syntax that is specific to your language.

Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download