From fae9e3123feecf94c8dff07ed705a24702ab15b7 Mon Sep 17 00:00:00 2001 From: paul-dingemans Date: Mon, 27 Nov 2023 18:01:54 +0100 Subject: [PATCH] Ignore invalid function names when importing from "junit.framework" Closes #2383 --- .../ruleset/standard/rules/FunctionNamingRule.kt | 1 + .../standard/rules/FunctionNamingRuleTest.kt | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/FunctionNamingRule.kt b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/FunctionNamingRule.kt index e39b7bd57f..6faf9cccfc 100644 --- a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/FunctionNamingRule.kt +++ b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/FunctionNamingRule.kt @@ -188,6 +188,7 @@ public class FunctionNamingRule : private val TEST_LIBRARIES_SET = setOf( "io.kotest", + "junit.framework", "kotlin.test", "org.junit", "org.testng", diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/FunctionNamingRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/FunctionNamingRuleTest.kt index a8517327a2..aabb1fb59e 100644 --- a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/FunctionNamingRuleTest.kt +++ b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/FunctionNamingRuleTest.kt @@ -257,4 +257,18 @@ class FunctionNamingRuleTest { """.trimIndent() functionNamingRuleAssertThat(code).hasNoLintViolations() } + + @Test + fun `Issue 2383 - Given a class with tests in JUnit3 style`() { + val code = + """ + import junit.framework.TestCase + + class FooTest : TestCase() { + fun testFoo_bar() { + } + } + """.trimIndent() + functionNamingRuleAssertThat(code).hasNoLintViolations() + } }