Package com.google.test.metric

Examples of com.google.test.metric.ClassCost$CostComparator


    assertTrue(text, text
        .contains("<a href=\"http://code.repository/basepath/com/google/FooClass.java&line"));
  }

  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();
View Full Code Here


    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

  }

  public void testAddOneClassCostThenPrintIt() throws Exception {
    DrillDownReportGenerator printer =
      new DrillDownReportGenerator(new PrintStream(out), costModel, null, MAX_VALUE, 0);
    ClassCost classCost0 = new ClassCost("FAKE_classInfo0", new ArrayList<MethodCost>());
    printer.addClassCost(classCost0);
    printer.printFooter();
    assertStringEquals("\nTestability cost for FAKE_classInfo0 [ cost = 0 ] [ 0 TCC, 0 TGC ]\n",
        out.toString());
  }
View Full Code Here

  }

  public void testAddSeveralClassCostsAndPrintThem() throws Exception {
    DrillDownReportGenerator printer =
      new DrillDownReportGenerator(new PrintStream(out), costModel, null, MAX_VALUE, 0);
    ClassCost classCost0 = new ClassCost("FAKE_classInfo0", new ArrayList<MethodCost>());
    ClassCost classCost1 = new ClassCost("FAKE_classInfo1", new ArrayList<MethodCost>());
    ClassCost classCost2 = new ClassCost("FAKE_classInfo2", new ArrayList<MethodCost>());
    printer.addClassCost(classCost0);
    printer.addClassCost(classCost1);
    printer.addClassCost(classCost2);
    printer.printFooter();
    assertStringEquals("\nTestability cost for FAKE_classInfo0 [ cost = 0 ] [ 0 TCC, 0 TGC ]\n" +
View Full Code Here

    methodCost2.link();
    List<MethodCost> methodCosts1 = new ArrayList<MethodCost>();
    methodCosts1.add(methodCost1);
    List<MethodCost> methodCosts2 = new ArrayList<MethodCost>();
    methodCosts2.add(methodCost2);
    ClassCost classCost0 = new ClassCost("FAKE_classInfo0", new ArrayList<MethodCost>());
    ClassCost classCost1 = new ClassCost("FAKE_classInfo1", methodCosts1);
    ClassCost classCost2 = new ClassCost("FAKE_classInfo2", methodCosts2);
    printer.addClassCost(classCost0);
    printer.addClassCost(classCost1);
    printer.addClassCost(classCost2);
    printer.printFooter();
    assertStringEquals("\nTestability cost for FAKE_classInfo2 [ cost = 2 ] [ 2 TCC, 0 TGC ]\n" +
View Full Code Here

      CostUtil.staticCost3();
    }
  }

  public void testCreateSourceReport() throws Exception {
    ClassCost classCost = computer.compute(TestClass.class.getCanonicalName());

    ClassReport classReport = report.createClassReport(classCost);
    Source source = classReport.getSource();
    MethodCost m1 = classCost.getMethodCost("void m1()");
    MethodCost m2 = classCost.getMethodCost("void m2()");
    Line l1 = source.getLine(m1.getMethodLineNumber());
    Line l2 = source.getLine(m2.getMethodLineNumber());

    assertTrue(l1.toString(), l1.toString().contains("staticCost4()"));
    assertEquals(4, l1.getCost().getCyclomaticComplexityCost());
View Full Code Here

    // next line needs to stay at line 83!!
    public void doThing() {} // LINE 83
  }

  public void testImplicitMethodInvocationIndicatesTheFileMatchingLineNumber() throws Exception {
    ClassCost classCost = computer.compute(HasImplicitCostFromOtherClass.class.getCanonicalName());
    ClassReport classReport = report.createClassReport(classCost);
    List<MethodCost> methodCostList = classReport.getSource().getLine(83).getMethodCosts();
    String violationText = methodCostList.get(0).getViolationCosts().get(0).toString();
    assertTrue(violationText, violationText.contains("HasSetterCost"));
  }
View Full Code Here

    ResourceBundleModel bundleModel = new ResourceBundleModel(getBundle("messages"), objectWrapper);
    model.setMessageBundle(bundleModel);
    generator = new FreemarkerReportGenerator(model, new PrintStream(out),
            "about/Report.html", configuration);
    generator.printHeader();
    generator.addClassCost(new ClassCost("com.google.test.metric.example.Lessons.SumOfPrimes1",
        asList(new MethodCost("", "foo()", 1, false, false, false))));
    generator.printFooter();

    String text = out.toString();
    assertTrue(text, text.contains(">SumOfPrimes1<"));
View Full Code Here

    assertEquals(2, methodCost.getTotalCost().getGlobalCost());
  }

  public void testGadgetTotalClassCosts() {
    // This class has no cost, because there are no global references or cyclomatic complexity.
    ClassCost classCost = decoratedComputer.compute(Gadget.class);
    assertEquals(0, classCost.getHighestMethodComplexityCost());
    assertEquals(0, classCost.getHighestMethodGlobalCost());
    assertEquals(0, classCost.getTotalComplexityCost());
    assertEquals(0, classCost.getTotalGlobalCost());
  }
View Full Code Here

  }

  public void testMutableGlobalTotalClassCosts() {
    // This class has a static mutable instance that exposes global state.
    // Contrast this with {@code FinalGlobalExampleTest#testFinalGlobalTotalClassCosts()}
    ClassCost classCost = decoratedComputer.compute(MutableGlobal.class);
    assertEquals(0, classCost.getHighestMethodComplexityCost());
    assertEquals(1, classCost.getHighestMethodGlobalCost());
    assertEquals(0, classCost.getTotalComplexityCost());
    assertEquals(2, classCost.getTotalGlobalCost());
  }
View Full Code Here

TOP

Related Classes of com.google.test.metric.ClassCost$CostComparator

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.