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

Test functions on custom test source sets are treated as non test functions #5896

Closed
JavierSegoviaCordoba opened this issue Mar 12, 2023 · 8 comments
Labels

Comments

@JavierSegoviaCordoba
Copy link
Contributor

Expected Behavior

Any test function should allow to use backticks and spaces even if it is not on an "official" test source set

Observed Behavior

I have created custom source sets for different type tests, testIntegration and testFunctional and the functions reported on those source sets are marked by detekt, for example:

@Test
fun `android configuration cache clean v1_0_0`() { // marked by detekt
    gradleTestKitTest("gradle-features/android configuration cache clean v1_0_0") {
        beforeTest()
        testConfigurationCache(expectTaskOutcome = TaskOutcome.SUCCESS)
    }
}

Steps to Reproduce

The repo with the function mentioned above can be found here


I know it is not a good solution, but Detekt should check if a source set contains the word test or Test in order to apply some rules or others as, I think, it is impossible to know if a custom source set or configuration is for tests or not.

@BraisGabin
Copy link
Member

I asume that you are using the default configuration. There that rule have this configuration:

    excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']

As you can see functionalTest is not listed there so it doesn't apply. You can just add it and everything should work as expected.

@schalkms
Copy link
Member

schalkms commented Apr 2, 2023

Since there is nothing actionable here, I close this issue. If not, please leave a comment.

@schalkms schalkms closed this as completed Apr 2, 2023
@JavierSegoviaCordoba
Copy link
Contributor Author

JavierSegoviaCordoba commented Apr 2, 2023

I missed this notification.

I think the rule should find for *Test instead of hardcoding some of the multiplatform targets.

@schalkms @BraisGabin should I open a different issue or this is valid for this feature request?

@schalkms
Copy link
Member

schalkms commented Apr 2, 2023

@JavierSegoviaCordoba If #5412 does not already fit for your use case, please add your thoughts to this issue.

@andersfischernielsen
Copy link

Does adding an additional excludes path to a rule in a custom Detekt configuration (with buildUponDefaultConfig = true) extend the default excludes list or override the default excludes list?

@schalkms
Copy link
Member

@andersfischernielsen to my knowledge, there is no merging but rather a overriding mechanism with buildUponDefaultConfig = true.

@andersfischernielsen
Copy link

That's a shame - I was hoping we could extend the existing excludes rather than replace them. But thanks nonetheless!

@schalkms
Copy link
Member

@andersfischernielsen related discussion, which essentially proposes a solution to your scenario.
#5977 (comment)

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

No branches or pull requests

4 participants