Class LinearScorer

java.lang.Object
com.spertus.jacquard.coverage.Scorer
com.spertus.jacquard.coverage.LinearScorer
Direct Known Subclasses:
LinearBranchScorer, LinearLineScorer

public class LinearScorer extends Scorer
A code coverage scorer that uses a linear equation to weight the branch coverage and line coverage.
  • Field Summary

    Fields inherited from class com.spertus.jacquard.coverage.Scorer

    maxScore
  • Constructor Summary

    Constructors
    Constructor
    Description
    LinearScorer(double branchWeight, double maxPoints)
    Creates a scorer that scales the branch percentage by the specified weight, which must be in the range [0, 1].
    LinearScorer(double branchWeight, double lineWeight, double maxPoints)
    Creates a scorer that scales the branch percentage and line percentage by the specified weights, which must both be in the range [0, 1] and add up to one.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    getMessage(double branchCoverage, double lineCoverage)
    Gets a message summarizing information about the coverage being tested.
    getResult(String name, double branchCoverage, double lineCoverage)
    Creates a result based on information generated by Jacoco.
    double
    score(double branchCoverage, double lineCoverage)
    Converts branch coverage and line coverage ratios into a score.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LinearScorer

      public LinearScorer(double branchWeight, double lineWeight, double maxPoints)
      Creates a scorer that scales the branch percentage and line percentage by the specified weights, which must both be in the range [0, 1] and add up to one.
      Parameters:
      branchWeight - how much to weight the branch coverage percentage
      lineWeight - how much to weight the line coverage percentage
      maxPoints - the maximum number of points
      Throws:
      ClientException - if either weight is not in the range [0, 1] or they do not add up to 1
    • LinearScorer

      public LinearScorer(double branchWeight, double maxPoints)
      Creates a scorer that scales the branch percentage by the specified weight, which must be in the range [0, 1]. The remainder of the score is determined by scaling the line percentage by (1-branchWeight).
      Parameters:
      branchWeight - how much to weight the branch coverage percentage
      maxPoints - the maximum number of points
      Throws:
      ClientException - if either weight is not in the range [0, 1]
  • Method Details

    • score

      public double score(double branchCoverage, double lineCoverage)
      Description copied from class: Scorer
      Converts branch coverage and line coverage ratios into a score.
      Specified by:
      score in class Scorer
      Parameters:
      branchCoverage - the branch coverage ratio [0, 1]
      lineCoverage - the line coverage ratio [0, 1]
      Returns:
      a nonnegative score
    • getResult

      public Result getResult(String name, double branchCoverage, double lineCoverage)
      Description copied from class: Scorer
      Creates a result based on information generated by Jacoco.
      Specified by:
      getResult in class Scorer
      Parameters:
      name - the name of the grader
      branchCoverage - the branch coverage ratio [0, 1]
      lineCoverage - the line coverage ratio [0, 1]
      Returns:
      the result
    • getMessage

      protected String getMessage(double branchCoverage, double lineCoverage)
      Gets a message summarizing information about the coverage being tested.
      Parameters:
      branchCoverage - the branch coverage ratio [0, 1]
      lineCoverage - the line coverage ratio [0, 1]
      Returns:
      a message