Category2)
CATEGORY=Category2 && runCategory
+ CATEGORY=test && runCategory
;;
Category3)
import org.sonarqube.tests.qualityModel.TechnicalDebtInIssueChangelogTest;
import org.sonarqube.tests.qualityModel.TechnicalDebtTest;
import org.sonarqube.tests.rule.RulesPageTest;
-import org.sonarqube.tests.test.CoverageTest;
-import org.sonarqube.tests.test.CoverageTrackingTest;
-import org.sonarqube.tests.test.NewCoverageTest;
-import org.sonarqube.tests.test.TestExecutionTest;
import static util.ItUtils.pluginArtifact;
import static util.ItUtils.xooPlugin;
@RunWith(Suite.class)
@Suite.SuiteClasses({
- // test
- CoverageTrackingTest.class,
- CoverageTest.class,
- NewCoverageTest.class,
- TestExecutionTest.class,
// issue
AutoAssignTest.class,
CommonRulesTest.class,
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.SonarScanner;
-import org.sonarqube.tests.Category2Suite;
import java.io.File;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.sonarqube.qa.util.Tester;
+import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.WsRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.getMeasuresAsDoubleByMetricKey;
public class CoverageTest {
- @ClassRule
- public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR;
-
- private static final String[] ALL_COVERAGE_METRICS = new String[] {
+ private static final String[] ALL_COVERAGE_METRICS = new String[]{
"line_coverage", "lines_to_cover", "uncovered_lines", "branch_coverage", "conditions_to_cover", "uncovered_conditions", "coverage",
"it_line_coverage", "it_lines_to_cover", "it_uncovered_lines", "it_branch_coverage", "it_conditions_to_cover", "it_uncovered_conditions", "it_coverage",
"overall_line_coverage", "overall_lines_to_cover", "overall_uncovered_lines", "overall_branch_coverage", "overall_conditions_to_cover", "overall_uncovered_conditions",
- "overall_coverage"
- };
+ "overall_coverage"};
+
+ @ClassRule
+ public static Orchestrator orchestrator = TestSuite.ORCHESTRATOR;
@Rule
- public Tester tester = new Tester(orchestrator).disableOrganizations();
+ public Tester tester = new Tester(orchestrator);
@Test
public void coverage() throws Exception {
assertThat(measures.get("overall_coverage")).isNull();
- String coverage = cleanupScmAndDuplication(orchestrator.getServer().adminWsClient().get("api/sources/lines", "key", "sample-ut-coverage:src/main/xoo/sample/Sample.xoo"));
+ GetRequest getRequest = new GetRequest("api/sources/lines").setParam("key", "sample-ut-coverage:src/main/xoo/sample/Sample.xoo");
+ String coverage = cleanupScmAndDuplication(tester.wsClient().wsConnector().call(getRequest).content());
// Use strict checking to be sure IT coverage is not present
JSONAssert.assertEquals(IOUtils.toString(this.getClass().getResourceAsStream("/test/CoverageTest/unit_test_coverage-expected.json"), "UTF-8"), coverage, true);
assertThat(measures.get("overall_coverage")).isNull();
- String coverage = cleanupScmAndDuplication(orchestrator.getServer().adminWsClient().get("api/sources/lines", "key", "sample-ut-coverage:src/main/xoo/sample/Sample.xoo"));
+ WsRequest getRequest = new GetRequest("api/sources/lines").setParam("key", "sample-ut-coverage:src/main/xoo/sample/Sample.xoo");
+ String coverage = cleanupScmAndDuplication(tester.wsClient().wsConnector().call(getRequest).content());
// Use strict checking to be sure IT coverage is not present
JSONAssert.assertEquals(IOUtils.toString(this.getClass().getResourceAsStream("/test/CoverageTest/unit_test_coverage_no_condition-expected.json"), "UTF-8"), coverage,
true);
assertThat(measures.get("overall_coverage")).isNull();
- String coverage = cleanupScmAndDuplication(orchestrator.getServer().adminWsClient().get("api/sources/lines", "key", "sample-it-coverage:src/main/xoo/sample/Sample.xoo"));
+ WsRequest getRequest = new GetRequest("api/sources/lines").setParam("key", "sample-it-coverage:src/main/xoo/sample/Sample.xoo");
+ String coverage = cleanupScmAndDuplication(tester.wsClient().wsConnector().call(getRequest).content());
// Use strict checking to be sure UT coverage is not present
JSONAssert.assertEquals(IOUtils.toString(this.getClass().getResourceAsStream("/test/CoverageTest/it_coverage-expected.json"), "UTF-8"), coverage, true);
assertThat(measures.get("overall_coverage")).isNull();
- String coverage = cleanupScmAndDuplication(orchestrator.getServer().adminWsClient().get("api/sources/lines", "key", "sample-overall-coverage:src/main/xoo/sample/Sample.xoo"));
+ WsRequest getRequest = new GetRequest("api/sources/lines").setParam("key", "sample-overall-coverage:src/main/xoo/sample/Sample.xoo");
+ String coverage = cleanupScmAndDuplication(tester.wsClient().wsConnector().call(getRequest).content());
// Use strict checking to be sure no extra coverage is present
JSONAssert.assertEquals(IOUtils.toString(this.getClass().getResourceAsStream("/test/CoverageTest/ut_and_it_coverage-expected.json"), "UTF-8"), coverage, true);
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.SonarScanner;
-import org.sonarqube.tests.Category2Suite;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.sonarqube.qa.util.Tester;
+import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.WsRequest;
import static util.ItUtils.projectDir;
public class CoverageTrackingTest {
@ClassRule
- public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR;
+ public static Orchestrator orchestrator = TestSuite.ORCHESTRATOR;
@Rule
- public Tester tester = new Tester(orchestrator).disableOrganizations();
+ public Tester tester = new Tester(orchestrator);
@Test
public void test_coverage_per_test() throws Exception {
orchestrator.executeBuilds(SonarScanner.create(projectDir("testing/xoo-sample-with-coverage-per-test")));
- String tests = orchestrator.getServer().adminWsClient().get("api/tests/list", "testFileKey", "sample-with-tests:src/test/xoo/sample/SampleTest.xoo");
+ WsRequest getRequest = new GetRequest("api/tests/list").setParam("testFileKey", "sample-with-tests:src/test/xoo/sample/SampleTest.xoo");
+ String tests = tester.wsClient().wsConnector().call(getRequest).content();
JSONAssert.assertEquals(IOUtils.toString(this.getClass().getResourceAsStream("/test/CoverageTrackingTest/tests-expected.json"), "UTF-8"), tests, false);
String covered_files = orchestrator.getServer().adminWsClient()
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.SonarScanner;
-import org.sonarqube.tests.Category2Suite;
import java.util.Map;
import org.assertj.core.data.Offset;
-import org.junit.BeforeClass;
import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
import org.sonarqube.ws.WsMeasures;
import static java.lang.Double.parseDouble;
public class NewCoverageTest {
- @ClassRule
- public static Orchestrator orchestrator = Category2Suite.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"};
- private static final String[] ALL_NEW_COVERAGE_METRICS = new String[] {
- "new_coverage", "new_line_coverage", "new_branch_coverage"
- };
+ @ClassRule
+ public static Orchestrator orchestrator = TestSuite.ORCHESTRATOR;
- @BeforeClass
- public static void analyze_project() {
- orchestrator.resetData();
+ @Rule
+ public Tester tester = new Tester(orchestrator);
+ @Test
+ public void new_coverage() throws Exception {
orchestrator.executeBuilds(SonarScanner.create(projectDir("testing/xoo-sample-new-coverage-v1"))
.setProperty("sonar.projectDate", "2015-02-01")
.setProperty("sonar.scm.disabled", "false"));
orchestrator.executeBuilds(SonarScanner.create(projectDir("testing/xoo-sample-new-coverage-v2"))
.setProperty("sonar.scm.disabled", "false"));
- }
- @Test
- public void new_coverage() throws Exception {
Map<String, WsMeasures.Measure> measures = getMeasuresWithVariationsByMetricKey(orchestrator, PROJECT_KEY, ALL_NEW_COVERAGE_METRICS);
assertThat(parseDouble(measures.get("new_coverage").getPeriods().getPeriodsValue(0).getValue())).isEqualTo(66.6d, DEFAULT_OFFSET);
assertThat(parseDouble(measures.get("new_line_coverage").getPeriods().getPeriodsValue(0).getValue())).isEqualTo(100d, DEFAULT_OFFSET);
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.SonarScanner;
-import org.sonarqube.tests.Category2Suite;
import java.util.Map;
import org.apache.commons.io.IOUtils;
-import org.junit.Before;
import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONAssert;
+import org.sonarqube.qa.util.Tester;
+import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.WsRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static util.ItUtils.getMeasuresAsDoubleByMetricKey;
public class TestExecutionTest {
@ClassRule
- public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR;
+ public static Orchestrator orchestrator = TestSuite.ORCHESTRATOR;
- @Before
- public void delete_data() {
- orchestrator.resetData();
- }
+ @Rule
+ public Tester tester = new Tester(orchestrator);
@Test
public void test_execution_details() throws Exception {
assertThat(measures.get("skipped_tests")).isEqualTo(1);
assertThat(measures.get("test_execution_time")).isEqualTo(8);
- String json = orchestrator.getServer().adminWsClient().get("api/tests/list", "testFileKey", "sample-with-tests:src/test/xoo/sample/SampleTest.xoo");
+ WsRequest getRequest = new GetRequest("api/tests/list").setParam("testFileKey", "sample-with-tests:src/test/xoo/sample/SampleTest.xoo");
+ String json = tester.wsClient().wsConnector().call(getRequest).content();
JSONAssert.assertEquals(IOUtils.toString(this.getClass().getResourceAsStream("/test/TestExecutionTest/expected.json"), "UTF-8"), json, false);
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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 org.sonarqube.tests.test;
+
+import com.sonar.orchestrator.Orchestrator;
+import org.junit.ClassRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+import static util.ItUtils.xooPlugin;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ CoverageTrackingTest.class,
+ CoverageTest.class,
+ NewCoverageTest.class,
+ TestExecutionTest.class,
+})
+public class TestSuite {
+
+ @ClassRule
+ public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
+ .addPlugin(xooPlugin())
+
+ // reduce memory for Elasticsearch
+ .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
+
+ .build();
+
+}