diff --git a/ktlint-ruleset-experimental/src/test/kotlin/com/pinterest/ktlint/ruleset/experimental/ExperimentalRuleSetProviderTest.kt b/ktlint-ruleset-experimental/src/test/kotlin/com/pinterest/ktlint/ruleset/experimental/ExperimentalRuleSetProviderTest.kt
new file mode 100644
index 0000000000..84db04cafe
--- /dev/null
+++ b/ktlint-ruleset-experimental/src/test/kotlin/com/pinterest/ktlint/ruleset/experimental/ExperimentalRuleSetProviderTest.kt
@@ -0,0 +1,8 @@
+package com.pinterest.ktlint.ruleset.experimental
+
+import com.pinterest.ktlint.test.RuleSetProviderTest
+
+class ExperimentalRuleSetProviderTest : RuleSetProviderTest(
+ rulesetClass = ExperimentalRuleSetProvider::class.java,
+ packageName = "com.pinterest.ktlint.ruleset.experimental"
+)
diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/StandardRuleSetProviderTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/StandardRuleSetProviderTest.kt
new file mode 100644
index 0000000000..919211d609
--- /dev/null
+++ b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/StandardRuleSetProviderTest.kt
@@ -0,0 +1,8 @@
+package com.pinterest.ktlint.ruleset.standard
+
+import com.pinterest.ktlint.test.RuleSetProviderTest
+
+class StandardRuleSetProviderTest : RuleSetProviderTest(
+ rulesetClass = StandardRuleSetProvider::class.java,
+ packageName = "com.pinterest.ktlint.ruleset.standard"
+)
diff --git a/ktlint-test/build.gradle b/ktlint-test/build.gradle
index f42dde6936..537624cd8a 100644
--- a/ktlint-test/build.gradle
+++ b/ktlint-test/build.gradle
@@ -8,4 +8,5 @@ dependencies {
implementation deps.kotlin.stdlib
implementation deps.kotlin.compiler
implementation deps.assertj
+ implementation deps.junit
}
diff --git a/ktlint-test/pom.xml b/ktlint-test/pom.xml
index 32708d945c..1d352d4d4d 100644
--- a/ktlint-test/pom.xml
+++ b/ktlint-test/pom.xml
@@ -29,6 +29,11 @@
assertj-core
${assertj.version}
+
+ junit
+ junit
+ ${junit.version}
+
diff --git a/ktlint-test/src/main/kotlin/com/pinterest/ktlint/test/RuleSetProviderTest.kt b/ktlint-test/src/main/kotlin/com/pinterest/ktlint/test/RuleSetProviderTest.kt
new file mode 100644
index 0000000000..72a988de01
--- /dev/null
+++ b/ktlint-test/src/main/kotlin/com/pinterest/ktlint/test/RuleSetProviderTest.kt
@@ -0,0 +1,29 @@
+package com.pinterest.ktlint.test
+
+import com.pinterest.ktlint.core.RuleSetProvider
+import java.io.File
+import org.assertj.core.api.Assertions.assertThat
+import org.junit.Test
+
+open class RuleSetProviderTest(
+ private val rulesetClass: Class,
+ private val packageName: String
+) {
+
+ @Test
+ fun checkAllRulesProvided() {
+ val srcLocation = rulesetClass.protectionDomain.codeSource.location.path
+ val rulesDir = File(srcLocation + packageName.replace(".", "/"))
+ val packageRules = rulesDir.listFiles()
+ ?.map { it.name.removeSuffix(".class") }
+ ?.filter { it.endsWith("Rule") }
+ ?: arrayListOf()
+
+ val provider = rulesetClass
+ val providerRules = provider.newInstance().get().rules.map { it::class.java.simpleName }
+ val diff = packageRules - providerRules
+ assertThat(diff)
+ .withFailMessage("%s is missing to provide the following rules: \n%s", provider.simpleName, diff.joinToString(separator = "\n"))
+ .hasSize(0)
+ }
+}