aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaury Levé2018-06-26 17:18:33 +0200
committerGitHub2018-06-26 17:18:33 +0200
commit6ad2eec7823ef033f8a37a4e9606b803ade7023a (patch)
tree44e5c585b164e6ef9978326908986c39148b0625
parent510ac865875fcd1ed4475a50f74fd3ed5f0de3d5 (diff)
downloadsonar-css-6ad2eec7823ef033f8a37a4e9606b803ade7023a.tar.bz2
Add unit test for rules regarding styelint key (#84)
-rw-r--r--sonar-css-plugin/src/test/java/org/sonar/css/plugin/RuleTest.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/sonar-css-plugin/src/test/java/org/sonar/css/plugin/RuleTest.java b/sonar-css-plugin/src/test/java/org/sonar/css/plugin/RuleTest.java
new file mode 100644
index 0000000..f842d4e
--- /dev/null
+++ b/sonar-css-plugin/src/test/java/org/sonar/css/plugin/RuleTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.plugin;
+
+import java.lang.reflect.InvocationTargetException;
+import org.junit.Test;
+import org.sonar.css.plugin.rules.CssRule;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class RuleTest {
+
+ @Test
+ public void class_name_should_match_stylelint_key() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
+ for (Class ruleClass : CssRules.getRuleClasses()) {
+ CssRule rule = (CssRule)ruleClass.getConstructor().newInstance();
+ String stylelintRuleKeyWithoutUnderscore = rule.stylelintKey().replace("-", "");
+ assertThat(ruleClass.getSimpleName()).isEqualToIgnoringCase(stylelintRuleKeyWithoutUnderscore);
+ }
+ }
+}