Package com.google.test.metric

Examples of com.google.test.metric.MethodCost


    // TCC 4 because it doesn't double count for the same offense within one method
    assertEquals(4, methodCost.getTotalCost().getCyclomaticComplexityCost());
  }

  public void testMultipleDifferentNonOverridibleMethodsTcc12Cost() throws Exception {
    MethodCost methodCost = cost("void methodTcc12BecauseMultipleDifferentNonOverridableMethodCalls()");
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getGlobalCost());
    assertEquals(12, methodCost.getTotalCost().getCyclomaticComplexityCost());
  }
View Full Code Here


    MetricComputer toDecorate = new MetricComputerBuilder().withClassRepository(repo).build();
    decoratedComputer = new MetricComputerJavaDecorator(toDecorate, repo);
  }

  public void testAccessingMutableStaticItselfDirectlyDoesntCountAgainstYou() throws Exception {
    MethodCost methodCost = decoratedComputer.compute(MutableGlobalExample.class,
        "com.google.test.metric.example.MutableGlobalState.MutableGlobalExample.Gadget getInstance()");
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());

    // Noteworthy: code which exposes global state to others does not have the cost itself.
    // TODO(jwolter): is this correct?
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getTotalCost().getGlobalCost());
  }
View Full Code Here

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

  public void testAccessingAFinalFieldDoesNotCountAgainstYouButInitialGlobalDoes() throws Exception {
    // This method goes into mutable global state (cost +1) and reads a final value (cost +0)
    MethodCost methodCost = decoratedComputer.compute(MutableGlobalExample.class,
        "java.lang.String getGlobalId()");
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
    // Total Global Cost of 1, because of the {@code mutableInstance}.
    assertEquals(1, methodCost.getTotalCost().getGlobalCost());
  }
View Full Code Here

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

  public void testAccessingANonFinalFieldCountsAgainstYou() throws Exception {
    // This method goes into mutable global state (cost +1) and reads a mutable value (cost +1)
    MethodCost methodCost = decoratedComputer.compute(MutableGlobalExample.class, "int getGlobalCount()");
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
    assertEquals(2, methodCost.getTotalCost().getGlobalCost());
  }
View Full Code Here

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

  public void testWritingANonFinalFieldCountsAgainstYou() throws Exception {
    // This method goes into mutable global state (cost +1) and changes a mutable value (cost +1)
    MethodCost methodCost = decoratedComputer.compute(MutableGlobalExample.class, "int globalIncrement()");
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
    assertEquals(2, methodCost.getTotalCost().getGlobalCost());
  }
View Full Code Here

    MetricComputer toDecorate = new MetricComputerBuilder().withClassRepository(repo).build();
    decoratedComputer = new MetricComputerJavaDecorator(toDecorate, repo);
  }

  public void testAccessingAFinalStaticIsOK() throws Exception {
    MethodCost methodCost = decoratedComputer.compute(FinalGlobalExample.class,
        "com.google.test.metric.example.MutableGlobalState.FinalGlobalExample.Gadget getInstance()");
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getTotalCost().getGlobalCost());
  }
View Full Code Here

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

  public void testAccessingAFinalFieldDoesNotCountAgainstYou() throws Exception {
    // This method goes into final global state (cost +0) and reads a final value (cost +0)
    MethodCost methodCost = decoratedComputer.compute(FinalGlobalExample.class,
        "java.lang.String getGlobalId()");
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getTotalCost().getGlobalCost());
  }
View Full Code Here

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

  public void testAccessingANonFinalFieldCountsAgainstYou() throws Exception {
    // This method goes into final global state (cost +0) and reads a mutable value (cost +1)
    MethodCost methodCost = decoratedComputer.compute(FinalGlobalExample.class, "int getGlobalCount()");
    assertEquals(1, methodCost.getTotalCost().getGlobalCost());
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
  }
View Full Code Here

    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
  }

  public void testWritingANonFinalFieldCountsAgainstYou() throws Exception {
    // This method goes into final global state (cost +0) and writes a mutable value (cost +1)
    MethodCost methodCost = decoratedComputer.compute(FinalGlobalExample.class, "int globalIncrement()");
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
    assertEquals(1, methodCost.getTotalCost().getGlobalCost());
  }
View Full Code Here

    MetricComputer toDecorate = new MetricComputerBuilder().withClassRepository(repo).build();
    decoratedComputer = new MetricComputerJavaDecorator(toDecorate, repo);
  }

  public void testOverridableTcc0Cost() throws Exception {
    MethodCost methodCost = cost("void methodOverridableTcc4()");
    assertEquals(4, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getGlobalCost());
    assertEquals(4, methodCost.getTotalCost().getCyclomaticComplexityCost());

    methodCost = cost("void methodTcc0BecauseOverridableMethodCalls()");
    assertEquals(0, methodCost.getCost().getCyclomaticComplexityCost());
    assertEquals(0, methodCost.getCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getGlobalCost());
    assertEquals(0, methodCost.getTotalCost().getCyclomaticComplexityCost());
  }
View Full Code Here

TOP

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

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.