Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
student:eclipse:eclemma [2020/01/17 16:07] bernstdhstudent:eclipse:eclemma [2025/08/21 16:18] (current) bernstdh
Line 1: Line 1:
- 
- 
 ===== The EclEmma Code Coverage Tool for Eclipse ===== ===== The EclEmma Code Coverage Tool for Eclipse =====
  
Line 14: Line 12:
  
  
-Eclipse supports a variety of different //launch modes//  (e.g., for running applications, for debugging applications, ...).  If EclEmma is installed, the workbench should include a button  that looks like {{eclemma_coverage-mode.gif}} for  launching in EclEmma coverage mode. (Note:  If this button is not visible, click on  <key>Window</key>-<key>Perspective</key>-<key>CustomizePerspective</key>,  expand the "Launch" item, check "Coverage", and click <key>OK</key>.)  Expanding this button allows you to launch EclEmma.+Eclipse supports a variety of different //launch modes//  (e.g., for running applications, for debugging applications, ...).  If EclEmma is installed, the workbench should include a button  that looks like {{eclemma_coverage-mode.gif|Coverage Mode}} for  launching in EclEmma coverage mode. (Note:  If this button is not visible, click on  <key>Window</key>-<key>Perspective</key>-<key>CustomizePerspective</key>,  expand the "Launch" item, check "Coverage", and click <key>OK</key>.)  Expanding this button allows you to launch EclEmma.
  
  
Line 23: Line 21:
  
  
-  - Expand the {{eclemma_coverage-mode.gif}} button and pull down to      <key>Coverage As</key>.+  - Expand the {{eclemma_coverage-mode.gif|Coverage Mode}} button and pull down to      <key>Coverage As</key>.
   - Select the appropriate type of coverage.   - Select the appropriate type of coverage.
  
Line 29: Line 27:
  
  
-Once you have selected the type of coverage, you can create a  coverage report by clicking on  {{eclemma_coverage-mode.gif}}. +Once you have selected the type of coverage, you can create a  coverage report by clicking on  {{eclemma_coverage-mode.gif}}. The coverage report will be available in the "Coverage" tab of the  Output View. (Note: If there is no "Coverage" tab you can enable  it by clicking on <key>Window</key>-<key>Show View</key>.)  This report provides a summary of the instructions covered by your tests (which is comparable to statement coverage).
  
-The coverage report will be available in the "Coverage" tab of the  Output View. (Note: If there is no "Coverage" tab you can enable  it by clicking on <key>Window</key>-<key>Show View</key>.)  In addition, each source file will be  [[ http://www.eclemma.org/userdoc/annotations.html | marked-up ]]  to indicate which  statements, branches, etc... have been covered and which have not.+**More importantly**, each source file will be  [[ http://www.eclemma.org/userdoc/annotations.html | marked-up ]]  to indicate which  statements, branches, etc... have been covered and which have not. (This is far more valuable and important than the coverage report.)
  
 Note that EclEmma uses the term "branch" differently from the way  some other people use the term. In EclEmma, the number of  "branches" is the sum of the number of possible Boolean values in  an expression. So, a statement like:  ''%%if ((x > 0) || (y > 0) || (z > 0))%%''  will have  2+2+2=6 "branches". Some people say this  statement has 2 "branches" (the entire expression is either true  or false, leading to 2 edges in the graph),  2×3=6 "conditions", and  23=8 "multiple conditions". Note that EclEmma uses the term "branch" differently from the way  some other people use the term. In EclEmma, the number of  "branches" is the sum of the number of possible Boolean values in  an expression. So, a statement like:  ''%%if ((x > 0) || (y > 0) || (z > 0))%%''  will have  2+2+2=6 "branches". Some people say this  statement has 2 "branches" (the entire expression is either true  or false, leading to 2 edges in the graph),  2×3=6 "conditions", and  23=8 "multiple conditions".
Line 40: Line 37:
  
  
-To remove the highlighting from a coverage report, click on  {{eclemma_remove-all-sessions.gif}} in the "Coverage" view.+To remove the highlighting from a coverage report, click on  {{eclemma_remove-all-sessions.gif|Coverage Mode}} in the "Coverage" view.
    
  
Line 46: Line 43:
  
  
-It is generally a good idea to create an individual JUnit tets for  each class (and sometimes for individual methods within a  class). However, when generating a coverage report you want to run  all of the tests in the suite. To do so, click on the triangle  on {{eclemma_coverage-mode.gif}} and pull down to  "Coverage configurations...". Then, select a JUnit test and click on  "Run all tests in the selected project, package, or folder" and click  on <key>Coverage</key>.+It is generally a good idea to create an individual JUnit tets for  each class (and sometimes for individual methods within a  class). However, when generating a coverage report you want to run  all of the tests in the suite. To do so, click on the triangle  on {{eclemma_coverage-mode.gif|Coverage Mode}} and pull down to  "Coverage configurations...". Then, select a JUnit test and click on  "Run all tests in the selected project, package, or folder" and click  on <key>Coverage</key>.
  
  
Line 52: Line 49:
  
  
-It's possible to have different versions of JUnit installed within Eclipse  at the same time. To use a particular test runner  click on the triangle  on {{eclemma_coverage-mode.gif}} and pull down to  "Coverage configurations...". Then, select a "Test runner" and  click on <key>Apply</key>.+It's possible to have different versions of JUnit installed within Eclipse  at the same time. To use a particular test runner  click on the triangle  on {{eclemma_coverage-mode.gif|Coverage Mode}} and pull down to  "Coverage configurations...". Then, select a "Test runner" and  click on <key>Apply</key>.
        
  
Line 84: Line 81:
  
  
-Java adds an automatic constructor to all classes that do not    have a constructor, including utility classes. So, unless you go    out of your way to do so, your test suite will not cover the    automatic constructor which means that the declaration of the    class may appear to be uncovered. If you want, you can construct    an instance of the utility class in one of your tests (and, so,    cover the automatic constructor).+Java adds an automatic constructor to all classes that do not have a constructor, including utility classes. So, unless you go    out of your way to do so, your test suite will not cover the  automatic constructor which means that the declaration of the    class may appear to be uncovered. To get complete coverage you can
 +  * Construct  an instance of the utility class in one of your tests (and, so,    cover the automatic constructor); or 
 +  * Add a private default constructor to the utility class.
  
 ==== Accessibility Settings ==== ==== Accessibility Settings ====