private Map<BlockLocation, Set<TestInfo>> blocksToMap( final Collection<BlockCoverage> coverageData) { final Map<BlockLocation, Set<TestInfo>> blockCoverageMap = new HashMap<>(); for (final BlockCoverage blockData : coverageData) { blockCoverageMap.put(blockData.getBlock(), new HashSet<>(FCollection.map(blockData.getTests(), toTestInfo(blockData)))); } return blockCoverageMap; }
private void writeLineCoverage(final BlockCoverage each, final Writer out) { final Location l = each.getBlock().getLocation(); write( out, "<block classname='" + l.getClassName().asJavaName() + "'" + " method='" + StringUtil.escapeBasicHtmlChars(l.getMethodName().name()) + StringUtil.escapeBasicHtmlChars(l.getMethodDesc()) + "' number='" + each.getBlock().getBlock() + "'>"); write(out, "<tests>\n"); final List<String> ts = new ArrayList<>(each.getTests()); Collections.sort(ts); for (final String test : ts) { write(out, "<test name='" + StringUtil.escapeBasicHtmlChars(test) + "'/>\n"); } write(out, "</tests>\n"); write(out, "</block>\n"); }
@Test public void shouldProvideCoverageListWhenCoverageRecorded() { final BlockLocationBuilder block = aBlockLocation().withLocation( aLocation().withClass(this.foo)); final CoverageResultBuilder cr = aCoverageResult().withVisitedBlocks( block.build(1)); this.testee.calculateClassCoverage(cr.build()); this.testee.calculateClassCoverage(makeCoverageResult("foo", "fooTest", 0, 1)); final BlockCoverage actual = this.testee.createCoverage().get(0); assertEquals(block.build(), actual.getBlock()); assertThat(actual.getTests()).contains("FooTest.fooTest"); }