Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classes that import io.kotest are not considered a test case #2289

Closed
martinvisser opened this issue Oct 2, 2023 · 1 comment · Fixed by #2291
Closed

Classes that import io.kotest are not considered a test case #2289

martinvisser opened this issue Oct 2, 2023 · 1 comment · Fixed by #2291
Milestone

Comments

@martinvisser
Copy link

Expected Behavior

With the promotion of function naming I now see errors like "Function name should start with a lowercase letter (except factory methods) and use camel case" even though this is within a test. In our test case we use Kotest and no org.junit is used. Expected behavior would be that these functions are also considered as valid, because it's a test case.

Current Behavior

The following test case is considered to have an invalid function name. According to Function naming tests are considered to have an import of org.junit, org.testng or kotlin.test, but this example doesn't have any. This is partially due to the choice of using Kotest, but also because this is part of a maven plugin that extends from rather ancient test style nearly forced upon by the Maven Plugin Testing Harness.

package some.package

import io.kotest.matchers.collections.shouldContainExactly
import io.kotest.matchers.maps.shouldContainKey
import kotlin.io.path.readLines

class AgentMojoTest : BaseMojoTest() {
    fun `test should write arg line`() { // considered as invalid
    }
}
package some.package

import org.apache.maven.plugin.testing.AbstractMojoTestCase

abstract class BaseMojoTest : AbstractMojoTestCase() {
}

Additional information

  • Current version of ktlint: 1.0.0
@paul-dingemans
Copy link
Collaborator

Indeed "io.kotest" is not on the ignore list in

it.startsWith(ORG_JUNIT) || it.startsWith(ORG_TESTNG) || it.startsWith(KOTLIN_TEST)
. It is an easy fix though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants