My favorites | Sign in
Google
                
Search
for
Updated Sep 18, 2008 by dmaclach
Labels: Featured
NonFeasibleCode  
How to clean up code coverage noise and mark code as un-executable.

Introduction

Sometimes certain sections of code are not feasible to test. To name a few, this includes:

To help you with these sections, CoverStory supports some special markings to tell it to ignore that code. These NF (non-feasible) markings should be used responsibly. They're added to help you eliminate noise in the data. You should aim for 100% coverage if you use this marking in your code.

Details

To mark a single line as non-feasible, add a // COV_NF_LINE to the end of the line. To mark a block as non-feasible, surround it with // COV_NF_START and // COV_NF_END.

Some code samples:

It excludes a particular line from coverage percentage calculation. It takes effect only when the given line is instrumented.
   if (all_hell_breaks_loose) {
      NSLog(@"The sky is falling! The sky is falling!");      // COV_NF_LINE
   }
It excludes the section of code falling into the range of the marker. The markers are inclusive, but don't nest.
   #ifdef OS_WINDOWS   // COV_NF_START
     do task a;
     ...
     do task z;
   #endif              // COV_NF_END

Xcode Script

There is a python script for the Xcode script menu named MarkAsCodeCoverageNonFeasible which greatly simplifies marking chunks of code as non-feasible for code coverage. Read the script for installation instructions.


Sign in to add a comment