use of hudson.plugins.cobertura.targets.CoverageResult in project phabricator-jenkins-plugin by uber.
the class CoberturaCoverageProvider method computeCoverage.
private void computeCoverage() {
AbstractBuild build = getBuild();
if (build == null) {
mHasComputedCoverage = true;
return;
}
// Check if there is a cobertura build action
CoberturaBuildAction coberturaAction = build.getAction(CoberturaBuildAction.class);
if (coberturaAction != null) {
mCoverageResult = coberturaAction.getResult();
if (mCoverageResult != null) {
computeLineCoverage();
}
mHasComputedCoverage = true;
return;
}
// Fallback to scanning for the reports
copyCoverageToJenkinsMaster(build);
File[] reports = getCoberturaReports(build);
CoverageResult result = null;
if (reports != null) {
for (File report : reports) {
try {
result = CoberturaCoverageParser.parse(report, result);
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to load " + report, e);
}
}
}
if (result != null) {
result.setOwner(build);
computeLineCoverage();
cleanupCoverageFilesOnJenkinsMaster();
}
if (result != null) {
result.setOwner(build);
}
mCoverageResult = result;
mHasComputedCoverage = true;
}
use of hudson.plugins.cobertura.targets.CoverageResult in project phabricator-jenkins-plugin by uber.
the class CoberturaCoverageProviderTest method getMockResult.
private CoverageResult getMockResult() {
Ratio ratio = Ratio.create(75.0f, 100.0f);
CoverageResult result = mock(CoverageResult.class);
when(result.getCoverage(CoverageMetric.LINE)).thenReturn(ratio);
return result;
}
use of hudson.plugins.cobertura.targets.CoverageResult in project phabricator-jenkins-plugin by uber.
the class CoberturaPluginCoverageProviderTest method getMockResult.
private CoverageResult getMockResult() {
Ratio ratio = Ratio.create(75.0f, 100.0f);
CoverageResult result = mock(CoverageResult.class);
when(result.getCoverage(CoverageMetric.LINE)).thenReturn(ratio);
return result;
}
use of hudson.plugins.cobertura.targets.CoverageResult in project phabricator-jenkins-plugin by uber.
the class CoberturaCoverageProviderTest method testConvertCobertura.
@WithoutJenkins
@Test
public void testConvertCobertura() {
CoverageResult result = getMockResult();
CodeCoverageMetrics metrics = CoberturaCoverageProvider.convertCobertura(result);
assertEquals(75.0f, metrics.getLineCoveragePercent(), 0.0f);
assertEquals(0.0f, metrics.getPackageCoveragePercent(), 0.0f);
}
use of hudson.plugins.cobertura.targets.CoverageResult in project phabricator-jenkins-plugin by uber.
the class CoberturaPluginCoverageProvider method computeMetrics.
@Override
protected void computeMetrics() {
CoverageResult coverageResult = buildAction.getResult();
metrics = convertCobertura(coverageResult);
}
Aggregations