Package org.jacoco.core.analysis

Examples of org.jacoco.core.analysis.CoverageBuilder


    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.analyzeClass(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


    final TargetLoader loader = new TargetLoader();
    target = (Target) loader.add(clazz, bytes).newInstance();
  }

  private ICounter analyze() {
    final CoverageBuilder builder = new CoverageBuilder();
    final ExecutionDataStore store = new ExecutionDataStore();
    data.collect(store, new SessionInfoStore(), false);
    final Analyzer analyzer = new Analyzer(store, builder);
    analyzer.analyzeClass(reader);
    final Collection<IClassCoverage> classes = builder.getClasses();
    assertEquals(1, classes.size(), 0.0);
    final IClassCoverage classCoverage = classes.iterator().next();
    for (final IMethodCoverage m : classCoverage.getMethods()) {
      if (m.getName().equals("test")) {
        return m.getComplexityCounter();
View Full Code Here

    }
  }

  private IBundleCoverage createBundle(final GroupElement group)
      throws IOException {
    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, resource.getName());
        in.close();
      }
    }
    final IBundleCoverage bundle = builder.getBundle(group.name);
    logBundleInfo(bundle, builder.getNoMatchClasses());
    return bundle;
  }
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

   * @throws IOException
   *             if class files can't be read
   */
  public IBundleCoverage createBundle(
      final ExecutionDataStore executionDataStore) throws IOException {
    final CoverageBuilder builder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(executionDataStore, builder);
    final File classesDir = new File(this.project.getBuild()
        .getOutputDirectory());

    @SuppressWarnings("unchecked")
    final List<File> filesToAnalyze = FileUtils.getFiles(classesDir,
        fileFilter.getIncludes(), fileFilter.getExcludes());

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

    final IBundleCoverage bundle = builder
        .getBundle(this.project.getName());
    logBundleInfo(bundle, builder.getNoMatchClasses());

    return bundle;
  }
View Full Code Here

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

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

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

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

    execFileLoader = new ExecFileLoader();
    execFileLoader.load(executionDataFile);
  }

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

    analyzer.analyzeAll(classesDirectory);

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

      AnalyzedNodes nodes = cache.get(location);
      if (nodes != null) {
        return nodes;
      }

      final CoverageBuilder builder = new CoverageBuilder();
      final Analyzer analyzer = new Analyzer(executiondata, builder);
      new ResourceTreeWalker(analyzer).walk(location);
      nodes = new AnalyzedNodes(builder.getClasses(), builder.getSourceFiles());
      cache.put(location, nodes);
      return nodes;
    } catch (Exception e) {
      throw new CoreException(EclEmmaStatus.BUNDLE_ANALYSIS_ERROR.getStatus(
          root.getElementName(), location, e));
View Full Code Here

      AnalyzedNodes nodes = cache.get(location);
      if (nodes != null) {
        return nodes;
      }

      final CoverageBuilder builder = new CoverageBuilder();
      final Analyzer analyzer = new Analyzer(executiondata, builder);
      new ResourceTreeWalker(analyzer).walk(location);
      nodes = new AnalyzedNodes(builder.getClasses(), builder.getSourceFiles());
      cache.put(location, nodes);
      return nodes;
    } catch (Exception e) {
      throw new CoreException(EclEmmaStatus.BUNDLE_ANALYSIS_ERROR.getStatus(
          root.getElementName(), location, e));
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.