Package org.jacoco.core.analysis

Examples of org.jacoco.core.analysis.CoverageBuilder


    fis.close();
  }

  private IBundleCoverage analyzeStructure() throws IOException {
    final CoverageBuilder coverageBuilder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(executionDataStore,
        coverageBuilder);

    analyzer.analyzeAll(classesDirectory);

    return coverageBuilder.getBundle(title);
  }
View Full Code Here


  private CoverageNodeImpl createNode(final GroupElement group,
      final ExecutionDataStore executionData) throws IOException {
    if (group.children.size() > 0) {
      return new CoverageNodeImpl(ElementType.GROUP, group.name, false);
    } else {
      final CoverageBuilder builder = new CoverageBuilder(executionData);
      final Analyzer analyzer = new Analyzer(builder);
      for (final Iterator<?> i = group.classfiles.iterator(); i.hasNext();) {
        final Resource resource = (Resource) i.next();
        if (resource.isDirectory() && resource instanceof FileResource) {
          analyzer.analyzeAll(((FileResource) resource).getFile());
          continue;
        }
        if (resource.getName().toLowerCase().endsWith(".jar")) {
          final InputStream in = resource.getInputStream();
          analyzer.analyzeJAR(in);
          in.close();
          continue;
        }
        if (resource.getName().toLowerCase().endsWith(".class")) {
          final InputStream in = resource.getInputStream();
          analyzer.analyze(in);
          in.close();
        }
      }
      return builder.getBundle(group.name);
    }
  }
View Full Code Here

          "To enable source code annotation class files have to be compiled with debug information.");
    }
  }

  private IBundleCoverage createBundle() throws IOException {
    final CoverageBuilder builder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(executionDataStore, builder);
    final File classesDir = new File(getProject().getBuild()
        .getOutputDirectory());
    analyzer.analyzeAll(classesDir);
    return builder.getBundle(getProject().getName());
  }
View Full Code Here

      throw new BuildException("Group name must be supplied");
    }
    if (group.children.size() > 0) {
      return new CoverageNodeImpl(ElementType.GROUP, group.name, false);
    } else {
      final CoverageBuilder builder = new CoverageBuilder(executionData);
      final Analyzer analyzer = new Analyzer(builder);
      for (final Iterator<?> i = group.classfiles.iterator(); i.hasNext();) {
        final Resource resource = (Resource) i.next();
        if (resource.isDirectory() && resource instanceof FileResource) {
          analyzer.analyzeAll(((FileResource) resource).getFile());
        } else {
          final InputStream in = resource.getInputStream();
          analyzer.analyzeAll(in);
          in.close();
        }
      }
      return builder.getBundle(group.name);
    }
  }
View Full Code Here

      throw new BuildException("Group name must be supplied");
    }
    if (group.children.size() > 0) {
      return new CoverageNodeImpl(ElementType.GROUP, group.name, false);
    } else {
      final CoverageBuilder builder = new CoverageBuilder(executionData);
      final Analyzer analyzer = new Analyzer(builder);
      for (final Iterator<?> i = group.classfiles.iterator(); i.hasNext();) {
        final Resource resource = (Resource) i.next();
        if (resource.isDirectory() && resource instanceof FileResource) {
          analyzer.analyzeAll(((FileResource) resource).getFile());
          continue;
        }
        if (resource.getName().toLowerCase().endsWith(".jar")) {
          final InputStream in = resource.getInputStream();
          analyzer.analyzeJAR(in);
          in.close();
          continue;
        }
        if (resource.getName().toLowerCase().endsWith(".class")) {
          final InputStream in = resource.getInputStream();
          analyzer.analyze(in);
          in.close();
        }
      }
      return builder.getBundle(group.name);
    }
  }
View Full Code Here

    runtime.collect(executionData, false);
    runtime.shutdown();

    // Together with the original class definition we can calculate coverage
    // information:
    final CoverageBuilder coverageBuilder = new CoverageBuilder(
        executionData);
    final Analyzer analyzer = new Analyzer(coverageBuilder);
    analyzer.analyze(getTargetClass(targetName));

    // Let's dump some metrics and line coverage information:
    for (final ClassCoverage cc : coverageBuilder.getClasses()) {
      System.out.printf("Coverage of class %s%n", cc.getSimpleName());

      printCounter("instructions", cc.getInstructionCounter());
      printCounter("lines", cc.getLineCounter());
      printCounter("methods", cc.getMethodCounter());
View Full Code Here

          "To enable source code annotation class files have to be compiled with debug information.");
    }
  }

  private IBundleCoverage createBundle() throws IOException {
    final CoverageBuilder builder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(executionDataStore, builder);
    final File classesDir = new File(getProject().getBuild()
        .getOutputDirectory());

    final List<File> filesToAnalyze = getFilesToAnalyze(classesDir);

    for (final File file : filesToAnalyze) {
      analyzer.analyzeAll(file);
    }

    return builder.getBundle(getProject().getName());
  }
View Full Code Here

  protected abstract void run(final Class<?> targetClass) throws Exception;

  private void analyze(final ClassReader reader,
      final ExecutionDataStore store) {
    final CoverageBuilder builder = new CoverageBuilder(store);
    final Analyzer analyzer = new Analyzer(builder);
    analyzer.analyze(reader);
    final Collection<ClassCoverage> classes = builder.getClasses();
    assertEquals(1, classes.size(), 0.0);
    classCoverage = classes.iterator().next();
    final Collection<SourceFileCoverage> files = builder.getSourceFiles();
    assertEquals(1, files.size(), 0.0);
    sourceCoverage = files.iterator().next();
    lineCoverage = sourceCoverage.getLines();
  }
View Full Code Here

  protected abstract void run(final Class<?> targetClass) throws Exception;

  private void analyze(final ClassReader reader,
      final ExecutionDataStore store) {
    final CoverageBuilder builder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(store, builder);
    analyzer.analyzeClass(reader);
    final Collection<IClassCoverage> classes = builder.getClasses();
    assertEquals(1, classes.size(), 0.0);
    classCoverage = classes.iterator().next();
    final Collection<ISourceFileCoverage> files = builder.getSourceFiles();
    assertEquals(1, files.size(), 0.0);
    sourceCoverage = files.iterator().next();
  }
View Full Code Here

      throw new BuildException("Group name must be supplied");
    }
    if (group.children.size() > 0) {
      return new CoverageNodeImpl(ElementType.GROUP, group.name);
    } else {
      final CoverageBuilder builder = new CoverageBuilder();
      final Analyzer analyzer = new Analyzer(executionDataStore, builder);
      for (final Iterator<?> i = group.classfiles.iterator(); i.hasNext();) {
        final Resource resource = (Resource) i.next();
        if (resource.isDirectory() && resource instanceof FileResource) {
          analyzer.analyzeAll(((FileResource) resource).getFile());
        } else {
          final InputStream in = resource.getInputStream();
          analyzer.analyzeAll(in);
          in.close();
        }
      }
      return builder.getBundle(group.name);
    }
  }
View Full Code Here

TOP

Related Classes of org.jacoco.core.analysis.CoverageBuilder

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.