diff options
Diffstat (limited to 'it')
15 files changed, 186 insertions, 0 deletions
diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v1/sonar-project.properties b/it/it-projects/testing/xoo-sample-new-coverage-v1/sonar-project.properties new file mode 100644 index 00000000000..a711b2bd89e --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v1/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectKey=sample-new-coverage +sonar.projectName=Sample new Coverage +sonar.projectVersion=1.0-SNAPSHOT +sonar.sources=src/main/xoo +sonar.language=xoo +sonar.scm.provider=xoo diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo new file mode 100644 index 00000000000..41871e123a3 --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo @@ -0,0 +1,16 @@ +package sample; + +public class Sample { + + public Sample(int i) { + int j = i++; + } + + private String myMethod() { + if (foo == bar) { + return "hello"; + } else { + throw new IllegalStateException(); + } + } +} diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.coverage b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.coverage new file mode 100644 index 00000000000..a2d656d1c9d --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.coverage @@ -0,0 +1 @@ +6:2:3:3 diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.itcoverage b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.itcoverage new file mode 100644 index 00000000000..a2d656d1c9d --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.itcoverage @@ -0,0 +1 @@ +6:2:3:3 diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.measures b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.measures new file mode 100644 index 00000000000..18b6b8eb944 --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.measures @@ -0,0 +1,2 @@ +ncloc:17 + diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.overallcoverage b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.overallcoverage new file mode 100644 index 00000000000..a2d656d1c9d --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.overallcoverage @@ -0,0 +1 @@ +6:2:3:3 diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.scm b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.scm new file mode 100644 index 00000000000..e047ea4394e --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v1/src/main/xoo/sample/Sample.xoo.scm @@ -0,0 +1,17 @@ +1,user1,2015-01-04 +1,user1,2015-01-04 +1,user1,2015-01-04 +1,user1,2015-01-04 +2,user2,2015-01-05 +2,user2,2015-01-05 +3,user3,2015-01-06 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v2/sonar-project.properties b/it/it-projects/testing/xoo-sample-new-coverage-v2/sonar-project.properties new file mode 100644 index 00000000000..a711b2bd89e --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v2/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectKey=sample-new-coverage +sonar.projectName=Sample new Coverage +sonar.projectVersion=1.0-SNAPSHOT +sonar.sources=src/main/xoo +sonar.language=xoo +sonar.scm.provider=xoo diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo new file mode 100644 index 00000000000..41871e123a3 --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo @@ -0,0 +1,16 @@ +package sample; + +public class Sample { + + public Sample(int i) { + int j = i++; + } + + private String myMethod() { + if (foo == bar) { + return "hello"; + } else { + throw new IllegalStateException(); + } + } +} diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.coverage b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.coverage new file mode 100644 index 00000000000..cd6fabd8eec --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.coverage @@ -0,0 +1,6 @@ +6:0:3:1 +7:1:3:1 +8:0 +9:1 +10:1 +11:1 diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.itcoverage b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.itcoverage new file mode 100644 index 00000000000..77bdb584a48 --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.itcoverage @@ -0,0 +1,5 @@ +6:0:3:1 +7:1:3:2 +8:1 +9:1 +10:1 diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.measures b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.measures new file mode 100644 index 00000000000..e4f33ed58ed --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.measures @@ -0,0 +1 @@ +ncloc:17 diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.overallcoverage b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.overallcoverage new file mode 100644 index 00000000000..ab5d844418e --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.overallcoverage @@ -0,0 +1,3 @@ +6:0:3:1 +7:1:3:2 +8:0:4:1 diff --git a/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.scm b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.scm new file mode 100644 index 00000000000..06d9b20756a --- /dev/null +++ b/it/it-projects/testing/xoo-sample-new-coverage-v2/src/main/xoo/sample/Sample.xoo.scm @@ -0,0 +1,17 @@ +1,user1,2015-01-04 +1,user1,2015-01-04 +1,user1,2015-01-04 +1,user1,2015-01-04 +2,user2,2015-01-05 +2,user2,2015-01-05 +3,user3,2015-06-06 +4,user4,2015-06-07 +4,user4,2015-06-07 +4,user4,2015-06-07 +4,user4,2015-06-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 +4,user4,2015-01-07 diff --git a/it/it-tests/src/test/java/testing/suite/NewCoverageTest.java b/it/it-tests/src/test/java/testing/suite/NewCoverageTest.java new file mode 100644 index 00000000000..29e7848dbb0 --- /dev/null +++ b/it/it-tests/src/test/java/testing/suite/NewCoverageTest.java @@ -0,0 +1,88 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package testing.suite; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import java.util.List; +import org.assertj.core.data.Offset; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.wsclient.services.Measure; +import org.sonar.wsclient.services.Resource; +import org.sonar.wsclient.services.ResourceQuery; + +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; + +public class NewCoverageTest { + + @ClassRule + public static Orchestrator orchestrator = TestingTestSuite.ORCHESTRATOR; + + private static final String PROJECT_KEY = "sample-new-coverage"; + + private static final Offset<Double> DEFAULT_OFFSET = Offset.offset(0.1d); + + private static final String[] ALL_NEW_COVERAGE_METRICS = new String[] { + "new_coverage", "new_line_coverage", "new_branch_coverage", + "new_it_coverage", "new_it_line_coverage", "new_it_branch_coverage", + "new_overall_coverage", "new_overall_line_coverage", "new_overall_branch_coverage" + }; + + @BeforeClass + public static void analyze_project() { + orchestrator.resetData(); + + orchestrator.executeBuilds(SonarRunner.create(projectDir("testing/xoo-sample-new-coverage-v1")) + .setProperty("sonar.projectDate", "2015-02-01") + .setProperty("sonar.scm.disabled", "false") + ); + orchestrator.executeBuilds(SonarRunner.create(projectDir("testing/xoo-sample-new-coverage-v2")) + .setProperty("sonar.scm.disabled", "false")); + } + + @Test + public void new_unit_test_coverage() throws Exception { + Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(PROJECT_KEY, ALL_NEW_COVERAGE_METRICS).setIncludeTrends(true)); + assertThat(project.getMeasure("new_coverage").getVariation1()).isEqualTo(62.5d, DEFAULT_OFFSET); + assertThat(project.getMeasure("new_line_coverage").getVariation1()).isEqualTo(80d, DEFAULT_OFFSET); + assertThat(project.getMeasure("new_branch_coverage").getVariation1()).isEqualTo(33.3, DEFAULT_OFFSET); + } + + @Test + public void new_integration_test_coverage() throws Exception { + Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(PROJECT_KEY, ALL_NEW_COVERAGE_METRICS).setIncludeTrends(true)); + assertThat(project.getMeasure("new_it_coverage").getVariation1()).isEqualTo(85.7, DEFAULT_OFFSET); + assertThat(project.getMeasure("new_it_line_coverage").getVariation1()).isEqualTo(100d, DEFAULT_OFFSET); + assertThat(project.getMeasure("new_it_branch_coverage").getVariation1()).isEqualTo(66.7, DEFAULT_OFFSET); + } + + @Test + public void new_overall_coverage() throws Exception { + Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(PROJECT_KEY, ALL_NEW_COVERAGE_METRICS).setIncludeTrends(true)); + assertThat(project.getMeasure("new_overall_coverage").getVariation1()).isEqualTo(44.4d, DEFAULT_OFFSET); + assertThat(project.getMeasure("new_overall_line_coverage").getVariation1()).isEqualTo(50d, DEFAULT_OFFSET); + assertThat(project.getMeasure("new_overall_branch_coverage").getVariation1()).isEqualTo(42.85, DEFAULT_OFFSET); + } + +} |