Package org.jacoco.report

Examples of org.jacoco.report.IReportVisitor


      throws IOException {

    // Create a concrete report visitor based on some supplied
    // configuration. In this case we use the defaults
    final HTMLFormatter htmlFormatter = new HTMLFormatter();
    final IReportVisitor visitor = htmlFormatter
        .createVisitor(new FileMultiReportOutput(reportDirectory));

    // Initialize the report with all of the execution and session
    // information. At this point the report doesn't know about the
    // structure of the report being created
    visitor.visitInfo(sessionInfoStore.getInfos(),
        executionDataStore.getContents());

    // Populate the report structure with the bundle coverage information.
    // Call visitGroup if you need groups in your report.
    visitor.visitBundle(bundleCoverage, new DirectorySourceFileLocator(
        sourceDirectory, "utf-8"));

    // Signal end of structure information to allow report to write all
    // information out
    visitor.visitEnd();

  }
View Full Code Here


  @Override
  public void execute() throws BuildException {
    loadExecutionData();
    try {
      final IReportVisitor visitor = createVisitor();
      visitor.visitInfo(sessionInfoStore.getInfos(),
          executionDataStore.getContents());
      createReport(visitor, structure);
      visitor.visitEnd();
    } catch (final IOException e) {
      throw new BuildException("Error while creating report.", e);
    }
  }
View Full Code Here

  public void testStructureWithNestedGroups() throws IOException {
    final ICoverageNode root = new CoverageNodeImpl(ElementType.GROUP,
        "root", false);
    final List<SessionInfo> sessions = Collections.emptyList();
    final Collection<ExecutionData> data = Collections.emptyList();
    final IReportVisitor child = formatter.createReportVisitor(root,
        sessions, data);
    driver.sendGroup(child);
    driver.sendGroup(child);
    child.visitEnd(driver.sourceFileLocator);
    final List<String> lines = getLines();
    assertEquals(HEADER, lines.get(0));
    assertEquals(
        "root/group/bundle,org.jacoco.example,FooClass,0,1,0,0,0,0,0,0",
        lines.get(1));
View Full Code Here

  }

  private void createReport(final IReportFormatter formatter)
      throws IOException {
    final CoverageNodeImpl node = createNode(structure);
    final IReportVisitor visitor = formatter.createReportVisitor(node,
        sessionInfoStore.getInfos(), executionDataStore.getContents());
    final SourceFileCollection sourceFileLocator = new SourceFileCollection(
        structure.sourcefiles);
    if (node instanceof BundleCoverage) {
      visitBundle(visitor, (BundleCoverage) node, sourceFileLocator);
    } else {
      for (final GroupElement g : structure.children) {
        createReport(g, visitor, node);
      }
    }
    visitor.visitEnd(sourceFileLocator);
  }
View Full Code Here

  private void createReport(final GroupElement group,
      final IReportVisitor parentVisitor,
      final CoverageNodeImpl parentNode) throws IOException {
    final CoverageNodeImpl node = createNode(group);
    final IReportVisitor visitor = parentVisitor.visitChild(node);
    final SourceFileCollection sourceFileLocator = new SourceFileCollection(
        group.sourcefiles);
    if (node instanceof BundleCoverage) {
      visitBundle(visitor, (BundleCoverage) node, sourceFileLocator);
    } else {
      for (final GroupElement g : group.children) {
        createReport(g, visitor, node);
      }
    }
    parentNode.increment(node);
    visitor.visitEnd(sourceFileLocator);
  }
View Full Code Here

  private static void visitLeafs(final IReportVisitor visitor,
      final Collection<? extends ICoverageNode> leafs,
      final ISourceFileLocator sourceFileLocator) throws IOException {
    for (final ICoverageNode l : leafs) {
      final IReportVisitor child = visitor.visitChild(l);
      child.visitEnd(sourceFileLocator);
    }
  }
View Full Code Here

  }

  private void createReport(final IReportFormatter formatter)
      throws IOException {
    final CoverageNodeImpl node = createNode(structure);
    final IReportVisitor visitor = formatter.createReportVisitor(node,
        sessionInfoStore.getInfos(), executionDataStore.getContents());
    final SourceFileCollection sourceFileLocator = new SourceFileCollection(
        structure.sourcefiles);
    if (node instanceof BundleCoverage) {
      visitBundle(visitor, (BundleCoverage) node, sourceFileLocator);
    } else {
      for (final GroupElement g : structure.children) {
        createReport(g, visitor, node);
      }
    }
    visitor.visitEnd(sourceFileLocator);
  }
View Full Code Here

  private void createReport(final GroupElement group,
      final IReportVisitor parentVisitor,
      final CoverageNodeImpl parentNode) throws IOException {
    final CoverageNodeImpl node = createNode(group);
    final IReportVisitor visitor = parentVisitor.visitChild(node);
    final SourceFileCollection sourceFileLocator = new SourceFileCollection(
        group.sourcefiles);
    if (node instanceof BundleCoverage) {
      visitBundle(visitor, (BundleCoverage) node, sourceFileLocator);
    } else {
      for (final GroupElement g : group.children) {
        createReport(g, visitor, node);
      }
    }
    parentNode.increment(node);
    visitor.visitEnd(sourceFileLocator);
  }
View Full Code Here

  private static void visitLeafs(final IReportVisitor visitor,
      final Collection<? extends ICoverageNode> leafs,
      final ISourceFileLocator sourceFileLocator) throws IOException {
    for (final ICoverageNode l : leafs) {
      final IReportVisitor child = visitor.visitChild(l);
      child.visitEnd(sourceFileLocator);
    }
  }
View Full Code Here

  @Test
  public void testSessionInfo() throws Exception {
    infos.add(new SessionInfo("session-1", 12345, 67890));
    infos.add(new SessionInfo("session-2", 1, 2));
    infos.add(new SessionInfo("session-3", 1, 2));
    final IReportVisitor visitor = formatter.createVisitor(output);
    visitor.visitInfo(infos, data);
    visitor.visitGroup("foo");
    visitor.visitEnd();
    assertPathMatches("session-1", "/report/sessioninfo[1]/@id");
    assertPathMatches("12345", "/report/sessioninfo[1]/@start");
    assertPathMatches("67890", "/report/sessioninfo[1]/@dump");
    assertPathMatches("session-2", "/report/sessioninfo[2]/@id");
    assertPathMatches("session-3", "/report/sessioninfo[3]/@id");
View Full Code Here

TOP

Related Classes of org.jacoco.report.IReportVisitor

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.