Package org.jacoco.core.data

Examples of org.jacoco.core.data.IClassStructureVisitor


  public IClassStructureVisitor visitClassStructure(final long id) {
    final ExecutionData data = executionData.get(id);
    final boolean[] covered = data == null ? null : data.getData();
    final Collection<MethodCoverage> methods = new ArrayList<MethodCoverage>();
    return new IClassStructureVisitor() {
      String name;
      String signature;
      String superName;
      String[] interfaces;
      String sourcename;
View Full Code Here


   *            VM name of the class
   * @return ASM visitor to write class definition to
   */
  public ClassVisitor createAnalyzingVisitor(final long classid,
      final String classname) {
    final IClassStructureVisitor classStructure = structureVisitor
        .visitClassStructure(classid, classname);
    return new ClassAnalyzer(classStructure);
  }
View Full Code Here

    coverageBuilder = new CoverageBuilder(executionData);
  }

  @Test
  public void testCreateClassNotCovered() {
    final IClassStructureVisitor classStructure = coverageBuilder
        .visitClassStructure(123L, "org/jacoco/examples/Sample");
    final IMethodStructureVisitor methodStructure = classStructure
        .visitMethodStructure(0, "doit", "()V", null);
    methodStructure.block(0, 5, new int[] { 6, 7, 8 });
    methodStructure.visitEnd();
    classStructure.visitEnd();

    final Collection<ClassCoverage> classes = coverageBuilder.getClasses();
    assertEquals(1, classes.size(), 1.0);
    ClassCoverage c = classes.iterator().next();
    assertEquals("org/jacoco/examples/Sample", c.getName());
View Full Code Here

  @Test
  public void testCreateClassCovered() {
    executionData.visitClassExecution(123L, "org/jacoco/examples/Sample",
        new boolean[][] { new boolean[] { true } });
    final IClassStructureVisitor classStructure = coverageBuilder
        .visitClassStructure(123L, "org/jacoco/examples/Sample");
    final IMethodStructureVisitor methodStructure = classStructure
        .visitMethodStructure(0, "doit", "()V", null);
    methodStructure.block(0, 5, new int[] { 6, 7, 8 });
    methodStructure.visitEnd();
    classStructure.visitEnd();

    final Collection<ClassCoverage> classes = coverageBuilder.getClasses();
    assertEquals(1, classes.size(), 1.0);
    ClassCoverage c = classes.iterator().next();
    assertEquals("org/jacoco/examples/Sample", c.getName());
View Full Code Here

    assertEquals(3, m.getLineCounter().getCoveredCount(), 0.0);
  }

  @Test
  public void testCreateSourceFile() {
    final IClassStructureVisitor classStructure1 = coverageBuilder
        .visitClassStructure(123L, "org/jacoco/examples/Sample");
    classStructure1.visitSourceFile("Sample.java");
    classStructure1.visitEnd();

    final IClassStructureVisitor classStructure2 = coverageBuilder
        .visitClassStructure(123L, "org/jacoco/examples/Sample");
    classStructure2.visitSourceFile("Sample.java");
    classStructure2.visitEnd();

    final Collection<SourceFileCoverage> sourcefiles = coverageBuilder
        .getSourceFiles();
    assertEquals(1, sourcefiles.size(), 1.0);
    SourceFileCoverage s = sourcefiles.iterator().next();
View Full Code Here

  public IClassStructureVisitor visitClassStructure(final long id,
      final String name) {
    final boolean[][] covered = executionData.getData(id);
    final Collection<MethodCoverage> methods = new ArrayList<MethodCoverage>();
    final String[] sourcename = new String[1];
    return new IClassStructureVisitor() {
      public void visitSourceFile(final String name) {
        sourcename[0] = name;
      }

      public IMethodStructureVisitor visitMethodStructure(final int id,
View Full Code Here

   * @param classid
   *            id of the class calculated with {@link CRC64}
   * @return ASM visitor to write class definition to
   */
  public ClassVisitor createAnalyzingVisitor(final long classid) {
    final IClassStructureVisitor classStructure = structureVisitor
        .visitClassStructure(classid);
    return new BlockClassAdapter(new ClassAnalyzer(classStructure));
  }
View Full Code Here

    coverageBuilder = new CoverageBuilder(executionData);
  }

  @Test
  public void testCreateClassMissed() {
    final IClassStructureVisitor classStructure = coverageBuilder
        .visitClassStructure(123L);
    classStructure.visit("org/jacoco/examples/Sample", null,
        "java/lang/Object", new String[0]);
    final IMethodStructureVisitor methodStructure = classStructure
        .visitMethodStructure("doit", "()V", null);
    methodStructure.block(0, 5, new int[] { 6, 7, 8 });
    methodStructure.visitEnd();
    classStructure.visitEnd();

    final Collection<ClassCoverage> classes = coverageBuilder.getClasses();
    assertEquals(1, classes.size(), 1.0);
    ClassCoverage c = classes.iterator().next();
    assertEquals("org/jacoco/examples/Sample", c.getName());
View Full Code Here

  @Test
  public void testCreateClassCovered() {
    executionData.visitClassExecution(123L, "org/jacoco/examples/Sample",
        new boolean[] { true });
    final IClassStructureVisitor classStructure = coverageBuilder
        .visitClassStructure(123L);
    classStructure.visit("org/jacoco/examples/Sample", null,
        "java/lang/Object", new String[0]);
    final IMethodStructureVisitor methodStructure = classStructure
        .visitMethodStructure("doit", "()V", null);
    methodStructure.block(0, 5, new int[] { 6, 7, 8 });
    methodStructure.visitEnd();
    classStructure.visitEnd();

    final Collection<ClassCoverage> classes = coverageBuilder.getClasses();
    assertEquals(1, classes.size(), 1.0);
    ClassCoverage c = classes.iterator().next();
    assertEquals("org/jacoco/examples/Sample", c.getName());
View Full Code Here

    assertEquals(3, m.getLineCounter().getCoveredCount(), 0.0);
  }

  @Test
  public void testIgnoreClassesWithoutCode() {
    final IClassStructureVisitor classStructure = coverageBuilder
        .visitClassStructure(123L);
    classStructure.visit("org/jacoco/examples/Sample", null,
        "java/lang/Object", new String[0]);
    final IMethodStructureVisitor methodStructure = classStructure
        .visitMethodStructure("doit", "()V", null);
    methodStructure.visitEnd();
    classStructure.visitEnd();

    final Collection<ClassCoverage> classes = coverageBuilder.getClasses();
    assertTrue(classes.isEmpty());
  }
View Full Code Here

TOP

Related Classes of org.jacoco.core.data.IClassStructureVisitor

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.