- Forward


EclEmma/JaCoCo
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Motivation
Back SMYC Forward
  • Purpose of Testing:
    • Identify faults (i.e. defects that could give rise to a failure)
  • An Observation:
    • If a test do not cause a particular piece of code to be executed it can't possibly identify a fault in that piece of code
Motivation (cont.)
Back SMYC Forward
  • What Test Tools/Harnesses/Frameworks Provide:
    • A way to write, organize, and run repeatable tests
  • What They Don't Provide:
    • A way to identify what pieces of code are and aren't executed
Overview of EclEmma/JaCoCo
Back SMYC Forward
  • Purpose:
    • Keep track of the statements and "branches" covered by a test (either using a test harness or a driver)
  • Output:
    • A hierarchical coverage report
    • A marked-up source file that indicates the coverage
A Note About Terminology
Back SMYC Forward
  • EclEmma/JaCoCo:
    • The number of "branches" is the sum of the number of possible Boolean values in an expression
  • Common Usage:
    • The number of "branches" is the number of edges in the execution graph (i.e., 2 for a Boolean expression, regardless of the number of sub-expressions, \(N\))
    • The number of "conditions" is the sum of the number of Boolean values (i.e., \(2N\))
    • The number of "multiple conditions" is the number of possible combinations (i.e., \(2^N\) in the worst case)
EclEmma/JaCoCo in an IDE
Back SMYC Forward
  • Launching:
    • There is usually a button to run the tests using EclEmma (e.g., eclemma_coverage-mode in Eclipse)
  • Coverage Report:
    • The hierarchical coverage report is usually available in the IDE (e.g., in the "Coverage" tab if the Output View in Eclipse)
      eclemma_coverage-report
    • It only show the instruction coverage (which is comparable to the statement coverage)
EclEmma/JaCoCo in an IDE (cont.)
Back SMYC Forward
  • Marked-Up Source:
    • The source code is usually color-coded and marked-up in other ways
      eclemma_marked-up-source-code
    • You can usually hover the cursor over the marked-up source to get more information
    • This information is far more valuable and important that the coverage report
  • Clearing the Mark-Up:
    • There is usually a button that allows you to clear the mark-up from the source code (e.g., eclemma_remove-all-sessions in Eclipse)
EclEmma/JaCoCo in an IDE (cont.)
Back SMYC Forward
  • Statement Mark-Up:
    • The statement itself is color-coded (green is fully covered, yellow is partly covered, red is uncovered)
  • "Branch" Markup:
    • A colored diamond is shown in the margin
  • Color Codes:
    • Green indicates full coverage
    • Yellow indicates partial coverage
    • Red indicates no coverage
There's Always More to Learn
Back -