diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-09-16 10:19:14 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-09-19 12:15:15 +0200 |
commit | e96ad852236cf56a778b3aa6af4c8fe94a1c5897 (patch) | |
tree | ab95a4afe94b6644e490e6ca9e579ac99ccc27d9 /it/it-tests/src | |
parent | c5f4811ce2b4ee1f373c31d104acda9c73a476b9 (diff) | |
download | sonarqube-e96ad852236cf56a778b3aa6af4c8fe94a1c5897.tar.gz sonarqube-e96ad852236cf56a778b3aa6af4c8fe94a1c5897.zip |
Fix NewDebtRatioMeasureTest
Diffstat (limited to 'it/it-tests/src')
-rw-r--r-- | it/it-tests/src/test/java/it/qualityModel/NewDebtRatioMeasureTest.java | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/it/it-tests/src/test/java/it/qualityModel/NewDebtRatioMeasureTest.java b/it/it-tests/src/test/java/it/qualityModel/NewDebtRatioMeasureTest.java index ae4f6a9e7e7..05e96062aed 100644 --- a/it/it-tests/src/test/java/it/qualityModel/NewDebtRatioMeasureTest.java +++ b/it/it-tests/src/test/java/it/qualityModel/NewDebtRatioMeasureTest.java @@ -22,11 +22,11 @@ package it.qualityModel; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.locator.FileLocation; import it.Category2Suite; +import java.util.Date; import java.util.List; import javax.annotation.Nullable; import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.sonar.wsclient.services.Measure; @@ -34,9 +34,13 @@ import org.sonar.wsclient.services.Resource; import org.sonar.wsclient.services.ResourceQuery; import util.ItUtils; +import static org.apache.commons.lang.time.DateUtils.addDays; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; +import static util.ItUtils.formatDate; +import static util.ItUtils.resetPeriods; import static util.ItUtils.setServerProperty; +import static util.ItUtils.toDate; /** * SONAR-5876 @@ -45,19 +49,16 @@ public class NewDebtRatioMeasureTest { private static final String NEW_DEBT_RATIO_METRIC_KEY = "new_sqale_debt_ratio"; + private static final Date FIRST_COMMIT_DATE = toDate("2016-09-01"); + private static final Date SECOND_COMMIT_DATE = toDate("2016-09-17"); + private static final Date THIRD_COMMIT_DATE = toDate("2016-09-20"); + @ClassRule public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; - @BeforeClass - public static void initPeriods() throws Exception { - setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis"); - setServerProperty(orchestrator, "sonar.timemachine.period2", "30"); - setServerProperty(orchestrator, "sonar.timemachine.period3", "previous_version"); - } - @AfterClass - public static void resetPeriods() throws Exception { - ItUtils.resetPeriods(orchestrator); + public static void reset() throws Exception { + resetPeriods(orchestrator); } @Before @@ -66,27 +67,27 @@ public class NewDebtRatioMeasureTest { } @Test - public void new_debt_ratio_is_computed_from_nes_debt_and_new_ncloc_count_per_file() throws Exception { - // This test assumes that period 1 is "since previous analysis" and 2 is "over 30 days" + public void new_debt_ratio_is_computed_from_new_debt_and_new_ncloc_count_per_file() throws Exception { + setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis"); + setServerProperty(orchestrator, "sonar.timemachine.period2", "30"); - // run analysis on the day of after the first commit (2015-09-01), with 'one-issue-per-line' profile - // => some issues at date 2015-09-02 + // run analysis on the day of after the first commit, with 'one-issue-per-line' profile defineQualityProfile("one-issue-per-line"); provisionSampleProject(); setSampleProjectQualityProfile("one-issue-per-line"); - runSampleProjectAnalysis("v1", "sonar.projectDate", "2015-09-02"); + runSampleProjectAnalysis("v1", "sonar.projectDate", formatDate(addDays(FIRST_COMMIT_DATE, 1))); // first analysis, no previous snapshot => periods not resolved => no value assertNoNewDebtRatio(); - // run analysis on the day after of second commit (2015-09-17) 'one-issue-per-line' profile* - // => 3 new issues will be created at date 2015-09-18 - runSampleProjectAnalysis("v2", "sonar.projectDate", "2015-09-18"); + // run analysis on the day after of second commit 'one-issue-per-line' profile* + // => 3 new issues will be created + runSampleProjectAnalysis("v2", "sonar.projectDate", formatDate(addDays(SECOND_COMMIT_DATE, 1))); assertNewDebtRatio(4.44, 4.44); - // run analysis on the day after of third commit (2015-09-20) 'one-issue-per-line' profile* - // => 4 new issues will be created at date 2015-09-21 - runSampleProjectAnalysis("v3", "sonar.projectDate", "2015-09-21"); + // run analysis on the day after of third commit 'one-issue-per-line' profile* + // => 4 new issues will be created + runSampleProjectAnalysis("v3", "sonar.projectDate", formatDate(addDays(THIRD_COMMIT_DATE, 1))); assertNewDebtRatio(4.17, 4.28); } @@ -119,8 +120,7 @@ public class NewDebtRatioMeasureTest { "measure/xoo-new-debt-ratio-" + projectVersion, ItUtils.concat(properties, // disable standard scm support so that it does not interfere with Xoo Scm sensor - "sonar.scm.disabled", "false") - ); + "sonar.scm.disabled", "false")); } private Resource getFileResourceWithVariations(String metricKey) { |