use of com.github.timurstrekalov.saga.core.model.ScriptCoverageStatistics in project saga by timurstrekalov.
the class DefaultCoverageGenerator method runTests.
private void runTests(final List<URI> tests, final int actualThreadCount, final OutputStrategy outputStrategy, final TestRunCoverageStatistics totalStats) throws IOException {
final ExecutorService executorService = Executors.newFixedThreadPool(actualThreadCount);
final CompletionService<TestRunCoverageStatistics> completionService = new ExecutorCompletionService<TestRunCoverageStatistics>(executorService);
for (final URI test : tests) {
completionService.submit(new TestRunCoverageStatisticsCallable(config, test, outputStrategy));
}
final List<TestRunCoverageStatistics> allRunStats = Lists.newLinkedList();
final int submittedTasks = tests.size();
try {
for (int i = 0; i < submittedTasks; i++) {
try {
final Future<TestRunCoverageStatistics> future = completionService.take();
final TestRunCoverageStatistics runStats = future.get();
allRunStats.add(runStats);
} catch (final Exception e) {
logger.debug(e.getMessage(), e);
}
}
} finally {
executorService.shutdown();
}
logger.info("Test run finished");
if (outputStrategy.contains(OutputStrategy.TOTAL)) {
for (final TestRunCoverageStatistics runStats : allRunStats) {
if (runStats != TestRunCoverageStatistics.EMPTY) {
for (final ScriptCoverageStatistics scriptCoverageStatistics : runStats) {
totalStats.add(scriptCoverageStatistics);
}
}
}
new WritesStatistics().write(config, totalStats);
}
}
use of com.github.timurstrekalov.saga.core.model.ScriptCoverageStatistics in project saga by timurstrekalov.
the class TestRunCoverageStatisticsCallable method collectAndWriteRunStats.
private TestRunCoverageStatistics collectAndWriteRunStats(final URI test, final Map<String, Map<String, Long>> coverageDataForAllScripts) throws IOException {
final TestRunCoverageStatistics runStats = new TestRunCoverageStatistics(test);
runStats.setSortBy(config.getSortBy());
runStats.setOrder(config.getOrder());
final URI baseUri = config.getBaseUri();
for (final ScriptData data : getLocalBrowser().getScriptDataList()) {
final String sourceUri = data.getSourceUriAsString();
@SuppressWarnings("unchecked") final Map<String, Long> coverageDataForScript = coverageDataForAllScripts.get(sourceUri);
final ScriptCoverageStatistics scriptCoverageStatistics = data.generateScriptCoverageStatistics(baseUri, coverageDataForScript);
runStats.add(scriptCoverageStatistics);
}
return runStats;
}
use of com.github.timurstrekalov.saga.core.model.ScriptCoverageStatistics in project saga by timurstrekalov.
the class PdfReporter method addFileStatsRows.
private void addFileStatsRows(final TestRunCoverageStatistics runStats, final PdfPTable table) {
final List<ScriptCoverageStatistics> allFileStats = runStats.getFileStats();
for (int i = 0; i < allFileStats.size(); i++) {
final ScriptCoverageStatistics scriptCoverageStatistics = allFileStats.get(i);
final boolean hasStatements = scriptCoverageStatistics.getHasStatements();
final Phrase fileName = new Phrase();
if (scriptCoverageStatistics.getParentName() != null) {
fileName.add(new Chunk(scriptCoverageStatistics.getParentName() + "/", hasStatements ? FONT_TD : FONT_TD_EMPTY_FILE));
fileName.add(new Chunk(scriptCoverageStatistics.getFileName(), hasStatements ? FONT_TD_BOLD : FONT_TD_BOLD_EMPTY_FILE));
} else {
fileName.add(new Chunk(scriptCoverageStatistics.getFileName(), hasStatements ? FONT_TD : FONT_TD_EMPTY_FILE));
}
final BaseColor bgColor = (i % 2 == 1) ? COLOR_ROW_ODD : COLOR_ROW_EVEN;
final Font font = FONT_TD;
table.addCell(createCell(fileName, 0, bgColor));
table.addCell(createCell(String.valueOf(scriptCoverageStatistics.getStatements()), font, 1, bgColor));
table.addCell(createCell(String.valueOf(scriptCoverageStatistics.getExecuted()), font, 2, bgColor));
table.addCell(createCell(scriptCoverageStatistics.getCoverage() + "%", FONT_TD, 3, bgColor));
}
}
Aggregations