Package org.jacoco.report

Examples of org.jacoco.report.IReportVisitor


          "Unable to read execution data file " + dataFile + ": "
              + e.getMessage(), e);
      return;
    }
    try {
      final IReportVisitor visitor = createVisitor();
      visitor.visitInfo(sessionInfoStore.getInfos(),
          executionDataStore.getContents());
      createReport(visitor);
      visitor.visitEnd();
    } catch (final Exception e) {
      getLog().error("Error while creating report: " + e.getMessage(), e);
    }
  }
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.getElementType() == ElementType.BUNDLE) {
      visitBundle(visitor, (IBundleCoverage) 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.getElementType() == ElementType.BUNDLE) {
      visitBundle(visitor, (IBundleCoverage) 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

  public void testStructureWithNestedGroups() throws IOException {
    final ICoverageNode root = new CoverageNodeImpl(ElementType.GROUP,
        "root");
    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

  @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

    assertPathMatches("session-3", "/report/sessioninfo[3]/@id");
  }

  @Test
  public void testStructureWithNestedGroups() throws Exception {
    final IReportVisitor visitor = formatter.createVisitor(output);
    visitor.visitInfo(infos, data);
    driver.sendNestedGroups(visitor);
    assertPathMatches("report", "/report/@name");
    assertPathMatches("group1", "/report/group[1]/@name");
    assertPathMatches("group", "/report/group[1]/group[1]/@name");
    assertPathMatches("bundle", "/report/group[1]/group[1]/group[1]/@name");
View Full Code Here

    assertPathMatches("bundle", "/report/group[2]/@name");
  }

  @Test
  public void testStructureWithGroup() throws Exception {
    final IReportVisitor visitor = formatter.createVisitor(output);
    visitor.visitInfo(infos, data);
    driver.sendGroup(visitor);
    assertPathMatches("group", "/report/@name");
    assertPathMatches("bundle", "/report/group/@name");
    assertPathMatches("org/jacoco/example", "/report/group/package/@name");
    assertPathMatches("org/jacoco/example/FooClass",
View Full Code Here

    assertPathMatches("1", "report/counter[@type='CLASS']/@covered");
  }

  @Test
  public void testStructureWithBundleOnly() throws Exception {
    final IReportVisitor visitor = formatter.createVisitor(output);
    visitor.visitInfo(infos, data);
    driver.sendBundle(visitor);
    assertPathMatches("bundle", "/report/@name");
    assertPathMatches("org/jacoco/example", "/report/package/@name");
    assertPathMatches("org/jacoco/example/FooClass",
        "/report/package/class/@name");
View Full Code Here

    assertPathMatches("1", "report/counter[@type='CLASS']/@covered");
  }

  @Test
  public void testDefaultEncoding() throws Exception {
    final IReportVisitor visitor = formatter.createVisitor(output);
    visitor.visitInfo(infos, data);
    driver.sendBundle(visitor);
    final BufferedReader reader = new BufferedReader(new InputStreamReader(
        output.getContentsAsStream(), "UTF-8"));
    final String line = reader.readLine();
    assertTrue(line,
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.