Package com.google.test.metric

Examples of com.google.test.metric.SourceLocation


  }

  public void testSecondLevelRecursive() throws Exception {
    DrillDownReportGenerator printer =
      new DrillDownReportGenerator(new PrintStream(out), costModel, null, MAX_VALUE, 0);
    methodCost3.addCostSource(new MethodInvocationCost(new SourceLocation(null, 1), methodCost2,
        NON_OVERRIDABLE_METHOD_CALL, Cost.cyclomatic(2)));
    methodCost2.addCostSource(new MethodInvocationCost(new SourceLocation(null, 2), methodCost2,
        NON_OVERRIDABLE_METHOD_CALL, new Cost()));
    methodCost3.link();
    printer.print("", methodCost3, 10);
    assertStringEquals("c.g.t.A.method3()V [CC: 5 / CC: 3]\n" +
      "  line 1: c.g.t.A.method2()V [CC: 2 / CC: 2] " + NON_OVERRIDABLE_METHOD_CALL + "\n",
View Full Code Here


public class MethodCostTest extends TestCase {

  public void testComputeOverallCost() throws Exception {
    MethodCost cost = new MethodCost("", "a", 0, false, false, false);
    cost.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    cost.addCostSource(new GlobalCost(new SourceLocation(null, 0), null, Cost.global(1)));
    MethodCost cost3 = new MethodCost("", "b", 0, false, false, false);
    cost3.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    cost3.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    cost3.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    cost.addCostSource(new MethodInvocationCost(new SourceLocation(null, 0), cost3,
        IMPLICIT_STATIC_INIT, Cost.cyclomatic(3)));
    CostModel costModel = new CostModel(2, 10, 1);
    cost.link();

    assertEquals((long) 2 * (3 + 1) + 10 * 1, costModel.computeOverall(cost.getTotalCost()));
View Full Code Here

  }

  private void addDirectCostIssue(ClassIssues classIssues, MethodCost methodCost,
                                  ClassCost classCost) {
    float contributionToClassCost = costModel.computeContributionFromMethod(classCost, methodCost);
    Issue issue = new Issue(new SourceLocation(classCost.getClassName(), methodCost.getMethodLineNumber()),
        methodCost.getDescription(), contributionToClassCost, null, null);
    if (methodCost.isConstructor()) {
      issue.setType(CONSTRUCTION);
      issue.setSubType(COMPLEXITY);
    } else {
View Full Code Here

TOP

Related Classes of com.google.test.metric.SourceLocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.