aboutsummaryrefslogtreecommitdiffstats
path: root/its
diff options
context:
space:
mode:
authorElena Vilchik2018-06-14 17:40:32 +0200
committerGitHub2018-06-14 17:40:32 +0200
commit6383829aa3b6b25975da1fe7c618e3f611d8c6e1 (patch)
tree25752e58f8ef71a3a3db849a987dc24a1f54e0f1 /its
parentb3887099d35a9d8909c00f43ca194cc02ba0b16a (diff)
downloadsonar-css-6383829aa3b6b25975da1fe7c618e3f611d8c6e1.tar.bz2
Integrate stylelint inside plugin (#42)
Diffstat (limited to 'its')
-rw-r--r--its/plugin/projects/css-plugin-test-project/src/file1.css2
-rw-r--r--its/plugin/src/test/java/org/sonar/css/its/IssuesTest.java57
-rw-r--r--its/plugin/src/test/java/org/sonar/css/its/Tests.java7
3 files changed, 61 insertions, 5 deletions
diff --git a/its/plugin/projects/css-plugin-test-project/src/file1.css b/its/plugin/projects/css-plugin-test-project/src/file1.css
index 5f9a55d..621aea1 100644
--- a/its/plugin/projects/css-plugin-test-project/src/file1.css
+++ b/its/plugin/projects/css-plugin-test-project/src/file1.css
@@ -2,7 +2,7 @@
background-color: #2d5e8b;
}
.class1 .class2 {
- background-color: #fff;
+ background-color: #ffw; /* issue here */
color: #2d5e8b;
foo: "some text";
}
diff --git a/its/plugin/src/test/java/org/sonar/css/its/IssuesTest.java b/its/plugin/src/test/java/org/sonar/css/its/IssuesTest.java
new file mode 100644
index 0000000..0f9de2e
--- /dev/null
+++ b/its/plugin/src/test/java/org/sonar/css/its/IssuesTest.java
@@ -0,0 +1,57 @@
+/*
+ * SonarCSS
+ * Copyright (C) 2018-2018 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.sonar.css.its;
+
+import com.sonar.orchestrator.Orchestrator;
+import java.util.Collections;
+import java.util.List;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonarqube.ws.Issues.Issue;
+import org.sonarqube.ws.client.issues.SearchRequest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.css.its.Tests.newWsClient;
+
+public class IssuesTest {
+
+ private static String PROJECT_KEY = "css-plugin-test-project";
+
+ @ClassRule
+ public static Orchestrator orchestrator = Tests.ORCHESTRATOR;
+
+ @BeforeClass
+ public static void prepare() {
+ orchestrator.executeBuild(Tests.createScanner(PROJECT_KEY));
+ }
+
+ @Test
+ public void test() {
+ SearchRequest request = new SearchRequest();
+ request.setComponentKeys(Collections.singletonList(PROJECT_KEY));
+ List<Issue> issuesList = newWsClient().issues().search(request).getIssuesList();
+
+ assertThat(issuesList).extracting("line").containsOnly(5);
+ assertThat(issuesList).extracting("component").containsOnly(PROJECT_KEY + ":src/file1.css");
+ assertThat(issuesList).extracting("rule").containsOnly("css:S4647");
+ }
+
+}
diff --git a/its/plugin/src/test/java/org/sonar/css/its/Tests.java b/its/plugin/src/test/java/org/sonar/css/its/Tests.java
index 4e38073..335bf6a 100644
--- a/its/plugin/src/test/java/org/sonar/css/its/Tests.java
+++ b/its/plugin/src/test/java/org/sonar/css/its/Tests.java
@@ -38,7 +38,8 @@ import org.sonarqube.ws.client.measures.ComponentRequest;
@RunWith(Suite.class)
@Suite.SuiteClasses({
- MetricsTest.class
+ MetricsTest.class,
+ IssuesTest.class
})
public class Tests {
@@ -49,11 +50,9 @@ public class Tests {
public static final Orchestrator ORCHESTRATOR;
static {
- String defaultRuntimeVersion = "true".equals(System.getenv("SONARSOURCE_QA")) ? null : "7.2.0.13185"; // TODO LATEST_RELEASE[7.2]
- String sqVersion = System.getProperty("sonar.runtimeVersion", defaultRuntimeVersion);
OrchestratorBuilder orchestratorBuilder = Orchestrator.builderEnv()
.addPlugin(PLUGIN_LOCATION)
- .setSonarVersion(sqVersion);
+ .setSonarVersion(System.getProperty("sonar.runtimeVersion", "7.2-RC1"));
ORCHESTRATOR = orchestratorBuilder.build();
}