ITK/Code Coverage Practices: Difference between revisions

From KitwarePublic
< ITK
Jump to navigationJump to search
(Created page with "__TOC__ = Overview = * The target code coverage is 95% * Historically we have only achieved 84%. * The practices described in this page should help us reach the target. = How ...")
 
 
(One intermediate revision by one other user not shown)
Line 41: Line 41:
* For example:
* For example:


         computeCodeCoverageLocallyForOneTest.sh -R  itkHDF5ImageIOTest
         computeCodeCoverageLocallyForOneTest.sh ./Modules/IO/HDF5 -R  itkHDF5ImageIOTest


* This will run the selected tests in ITK and generate code coverage for the entire toolkit, but only from the test that you have selected. The code coverage report will be generated in HTML and will be presented with Firefox.
* This will run the selected tests in ITK and generate code coverage for the entire toolkit, but only from the test that you have selected. The code coverage report will be generated in HTML and will be presented with Firefox.

Latest revision as of 01:26, 11 February 2012

Overview

  • The target code coverage is 95%
  • Historically we have only achieved 84%.
  • The practices described in this page should help us reach the target.

How to compute Code Coverage locally

Step 1

  • Use Linux or Mac

Step 2

  • Add the CMake flags:
      CMAKE_CXX_FLAGS:STRING=-g -O0  -fprofile-arcs -ftest-coverage
      CMAKE_C_FLAGS:STRING= -g -O0  -fprofile-arcs -ftest-coverage

Step 3

  • Configure to compile ITK for Debug
  • by setting the CMake variable
                    CMAKE_BUILD_TYPE  Debug

Step 4

  • From the binary directory type the "ctest" expression that select the tests that you want use to generate coverage (Ideally this should only need to be the unit tests of the class in question).
  • For example:
               ctest  -R   itkHDF5ImageIOTest   -V   -N
  • This will print to the console the command line instructions needed to run the tests (-V option), but without running the tests (-N option).

Step 5

  • From the binary directory type the path to this script in the ITK source tree and add the selection expression that you put in front of ctest.
  • For example:
       computeCodeCoverageLocallyForOneTest.sh ./Modules/IO/HDF5 -R  itkHDF5ImageIOTest
  • This will run the selected tests in ITK and generate code coverage for the entire toolkit, but only from the test that you have selected. The code coverage report will be generated in HTML and will be presented with Firefox.