use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class NewCoverageMeasuresStepTest method no_measure_for_unit_test_FILE_component.
@Test
public void no_measure_for_unit_test_FILE_component() {
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(true, null, 1)).build());
underTest.execute(new TestComputationStepContext());
assertThat(measureRepository.isEmpty()).isTrue();
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class NewCoverageMeasuresStepTest method verify_aggregates_variations.
private void verify_aggregates_variations(LinesAndConditionsWithUncoveredMetricKeys metricKeys, String codeCoverageKey, String lineCoverageKey, String branchCoverageKey) {
treeRootHolder.setRoot(MULTIPLE_FILES_TREE);
measureRepository.addRawMeasure(FILE_1_REF, metricKeys.getLines(), createMeasure(3000d)).addRawMeasure(FILE_1_REF, metricKeys.getConditions(), createMeasure(300d)).addRawMeasure(FILE_1_REF, metricKeys.getUncoveredLines(), createMeasure(30d)).addRawMeasure(FILE_1_REF, metricKeys.getUncoveredConditions(), createMeasure(9d)).addRawMeasure(FILE_2_REF, metricKeys.getLines(), createMeasure(2000d)).addRawMeasure(FILE_2_REF, metricKeys.getConditions(), createMeasure(400d)).addRawMeasure(FILE_2_REF, metricKeys.getUncoveredLines(), createMeasure(200d)).addRawMeasure(FILE_2_REF, metricKeys.getUncoveredConditions(), createMeasure(16d));
underTest.execute(new TestComputationStepContext());
assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(98.8d)), entryOf(lineCoverageKey, createMeasure(99d)), entryOf(branchCoverageKey, createMeasure(97d)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(91d)), entryOf(lineCoverageKey, createMeasure(90d)), entryOf(branchCoverageKey, createMeasure(96d)));
assertThat(measureRepository.getAddedRawMeasures(FILE_3_REF)).isEmpty();
assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_1_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(98.8d)), entryOf(lineCoverageKey, createMeasure(99d)), entryOf(branchCoverageKey, createMeasure(97d)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_2_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(91d)), entryOf(lineCoverageKey, createMeasure(90d)), entryOf(branchCoverageKey, createMeasure(96d)));
MeasureRepoEntry[] modulesAndProjectEntries = { entryOf(codeCoverageKey, createMeasure(95.5d)), entryOf(lineCoverageKey, createMeasure(95.4d)), entryOf(branchCoverageKey, createMeasure(96.4d)) };
assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(modulesAndProjectEntries);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class NewCoverageMeasuresStepTest method zero_measures_for_FILE_component_without_CoverageData.
@Test
public void zero_measures_for_FILE_component_without_CoverageData() {
treeRootHolder.setRoot(FILE_1);
setNewLines(FILE_1);
underTest.execute(new TestComputationStepContext());
verify_only_zero_measures_on_new_lines_and_conditions_measures(FILE_1);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class NewCoverageMeasuresStepTest method verify_computation_of_measures_for_new_lines_for_FILE.
@Test
public void verify_computation_of_measures_for_new_lines_for_FILE() {
when(newLinesRepository.newLinesAvailable()).thenReturn(true);
treeRootHolder.setRoot(FILE_COMPONENT);
setNewLines(FILE_1, 1, 2, 4);
reportReader.putCoverage(FILE_COMPONENT.getReportAttributes().getRef(), asList(ScannerReport.LineCoverage.newBuilder().setLine(2).setHits(false).build(), ScannerReport.LineCoverage.newBuilder().setLine(3).setHits(true).build(), ScannerReport.LineCoverage.newBuilder().setLine(4).setHits(true).build()));
underTest.execute(new TestComputationStepContext());
assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_COMPONENT.getReportAttributes().getRef()))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(2d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(1d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(0d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(0d)));
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class NewCoverageMeasuresStepTest method no_measure_for_DIRECTORY_component.
@Test
public void no_measure_for_DIRECTORY_component() {
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.DIRECTORY, DIRECTORY_1_REF).build());
underTest.execute(new TestComputationStepContext());
assertThat(measureRepository.isEmpty()).isTrue();
}
Aggregations