Package org.jacoco.report

Examples of org.jacoco.report.IReportVisitor


  @Test
  public void testStructureWithNestedGroups() throws IOException {
    final ICoverageNode root = new CoverageNodeImpl(ElementType.GROUP,
        "root", false);
    final IReportVisitor child = formatter.createReportVisitor(root);
    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 GroupElement group,
      final IReportFormatter formatter,
      final ExecutionDataStore executionData) throws IOException {
    final CoverageNodeImpl node = createNode(group, executionData);
    final IReportVisitor visitor = formatter.createReportVisitor(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, executionData);
      }
    }
    visitor.visitEnd(sourceFileLocator);
  }
View Full Code Here

  private void createReport(final GroupElement group,
      final IReportVisitor parentVisitor,
      final CoverageNodeImpl parentNode,
      final ExecutionDataStore executionData) throws IOException {
    final CoverageNodeImpl node = createNode(group, executionData);
    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, executionData);
      }
    }
    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

        support.findStr(doc, "//report/package/@name"));
  }

  @Test
  public void testClass() throws Exception {
    final IReportVisitor packageHandler = handler
        .visitChild(new CoverageNodeImpl(ElementType.PACKAGE,
            "org.jacoco.example", false));
    packageHandler.visitChild(
        new CoverageNodeImpl(ElementType.CLASS, "Foo", true)).visitEnd(
        null);
    packageHandler.visitEnd(null);
    final Document doc = getDocument();
    assertEquals("Foo",
        support.findStr(doc, "//report/package/class/@name"));
  }
View Full Code Here

        support.findStr(doc, "//report/package/class/@name"));
  }

  @Test
  public void testMethod() throws Exception {
    final IReportVisitor packageHandler = handler
        .visitChild(new CoverageNodeImpl(ElementType.PACKAGE,
            "org.jacoco.example", false));
    final IReportVisitor classHandler = packageHandler
        .visitChild(new CoverageNodeImpl(ElementType.CLASS, "Foo", true));
    MethodCoverage node = new MethodCoverage("doit", "()V", null);
    node.addBlock(5, new int[] { 15, 16, 17 }, false);
    classHandler.visitChild(node).visitEnd(null);
    classHandler.visitEnd(null);
    packageHandler.visitEnd(null);
    final Document doc = getDocument();
    assertEquals("doit",
        support.findStr(doc, "//report/package/class/method/@name"));
    assertEquals("()V",
View Full Code Here

        support.findStr(doc, "//report/package/class/method/@line"));
  }

  @Test
  public void testSourcefile() throws Exception {
    final IReportVisitor packageHandler = handler
        .visitChild(new CoverageNodeImpl(ElementType.PACKAGE,
            "org.jacoco.example", false));
    final CoverageNodeImpl node = new CoverageNodeImpl(
        ElementType.SOURCEFILE, "Foo.java", true) {
      {
        lines.increment(new int[] { 11, 13 }, false);
        lines.increment(new int[] { 13, 14 }, true);
      }
    };
    packageHandler.visitChild(node).visitEnd(null);
    packageHandler.visitEnd(null);
    final Document doc = getDocument();
    assertEquals("Foo.java",
        support.findStr(doc, "//report/package/sourcefile/@name"));
    assertEquals("11",
        support.findStr(doc, "//report/package/sourcefile/line[1]/@nr"));
View Full Code Here

  private void createReport(final GroupElement group,
      final IReportFormatter formatter,
      final ExecutionDataStore executionData) throws IOException {
    final CoverageNodeImpl node = createNode(group, executionData);
    final IReportVisitor visitor = formatter.createReportVisitor(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, executionData);
      }
    }
    visitor.visitEnd(sourceFileLocator);
  }
View Full Code Here

  private void createReport(final GroupElement group,
      final IReportVisitor parentVisitor,
      final CoverageNodeImpl parentNode,
      final ExecutionDataStore executionData) throws IOException {
    final CoverageNodeImpl node = createNode(group, executionData);
    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, executionData);
      }
    }
    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

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.