Package com.google.test.metric

Examples of com.google.test.metric.SourceLocation


  public void testConstructorCosts() throws Exception {
    ClassCost cost =
        new ClassCost("classFoo", Arrays.asList(new MethodCost("", "methodFoo", 1, false, false, false)));
    ClassIssues classIssues = new ClassIssues(cost.getClassName(), 0);
    classIssues.add(new Issue(new SourceLocation("", 1), null, 1f, null, null));
    importantIssues.add(classIssues);
    generator.printHeader();
    generator.addClassCost(cost);
    generator.printFooter();
    String text = out.toString();
View Full Code Here


  private ClassCost classCost(String name, int cost) {
    List<MethodCost> methods = new ArrayList<MethodCost>();
    MethodCost methodCost = new MethodCost("", "method_" + cost, 1, false, false, false);
    for (int i = 0; i < cost; i++) {
      methodCost.addCostSource(new CyclomaticCost(new SourceLocation(null, i), Cost.cyclomatic(1)));
    }
    methodCost.link();
    methods.add(methodCost);
    ClassCost classCost = new ClassCost(name, methods);
    return classCost;
View Full Code Here

  private final ByteArrayOutputStream out = new ByteArrayOutputStream();
  private final CostModel costModel = new CostModel();

  @Override
  protected void setUp() throws Exception {
    methodCost1.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));

    methodCost2.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    methodCost2.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));

    methodCost3.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    methodCost3.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    methodCost3.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
}
View Full Code Here

  public void testSimpleCost() throws Exception {
    DrillDownReportGenerator printer =
      new DrillDownReportGenerator(new PrintStream(out), costModel, null, MAX_VALUE, 0);
    MethodCost costOnlyMethod1 = new MethodCost("", "c.g.t.A.method1()V", 0, false, false, false);
    costOnlyMethod1.addCostSource(new CyclomaticCost(new SourceLocation(null, 1), Cost.cyclomatic(1)));
    costOnlyMethod1.addCostSource(new GlobalCost(new SourceLocation(null, 0), null, Cost.global(1)));
    costOnlyMethod1.link();
    printer.print("", costOnlyMethod1, Integer.MAX_VALUE);
    assertStringEquals("c.g.t.A.method1()V [CC: 1, GC: 1 / CC: 1, GC: 1]\n", out.toString());
  }
View Full Code Here

  }

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

  }

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

  }

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

  }

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

  }

  public void testSupressAllWhenMinCostIs4() throws Exception {
    DrillDownReportGenerator printer =
      new DrillDownReportGenerator(new PrintStream(out), costModel, null, MAX_VALUE, 4);
    methodCost2.addCostSource(new MethodInvocationCost(new SourceLocation(null, 81), methodCost1,
        NON_OVERRIDABLE_METHOD_CALL, Cost.cyclomatic(1)));
    methodCost2.link();
    printer.print("", methodCost2, MAX_VALUE);
    assertStringEquals("", out.toString());
  }
View Full Code Here

  }

  public void testSupressPartialWhenMinCostIs2() throws Exception {
    DrillDownReportGenerator printer =
      new DrillDownReportGenerator(new PrintStream(out), costModel, null, MAX_VALUE, 2);
    methodCost2.addCostSource(new MethodInvocationCost(new SourceLocation(null, 81), methodCost1,
        NON_OVERRIDABLE_METHOD_CALL, Cost.cyclomatic(1)));
    methodCost2.link();
    printer.print("", methodCost2, Integer.MAX_VALUE);
    assertStringEquals("c.g.t.A.method2()V [CC: 3 / CC: 2]\n", out.toString());
  }
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.