Marcin Wisniowski
09/13/2023, 3:59 PM@Suppress("Use cases are in a usecase package")
does not work.igor.wojda
09/14/2023, 7:57 AMKoDeclarationAndProviderAssertCore.kt
file. I am happy to help kicking this off.igor.wojda
09/14/2023, 8:16 AMJonathan Sarco
09/14/2023, 8:29 AMigor.wojda
09/14/2023, 11:08 AM@Supress
annotation you need to pass name
(ot the check that you want to suppress). Konsist is retrieving this method name by using call stack of current thread (CommonAssert.kt
contains methods used in KoDeclarationAndProviderAssertCore.kt
).
KoTest is using custom DSL, so I am not even sure if this approach will work for Konsist. I am not sure if name can be retrieved in this context.
The best approach would be to try to get kotest test name inside KoDeclarationAndProviderAssertCore.kt
). See https://github.com/kotest/kotest/issues/3546
If the above approach will fail we will have to introduce a new nullable argument to both assert
and assertNot
methods (KoDeclarationAndProviderAssertCore.kt
) called suppressName
.
They way it could work is that:
• If suppressName
argument is passed then use this name as the test name to be supresses
• If suppressName
argument is not passed then default to function name (that will obviously work only for JUnit tests)
Code
...
.classes()
.assert(suppressName = "my konsist test") {
....
}
Production code
@Suppress("my konsist test")
class Car
Jonathan Sarco
09/15/2023, 6:51 AMJonathan Sarco
09/16/2023, 4:30 PMKoDeclarationAndProviderAssertCore.kt
. Because the context is different (at least for now, I couldn’t get it. It should be a way 💡).
What I can do it’s the second option, using a suppress name
when calling the assert method (I think this should be improved, not the cleanest way I would say).
So taking the context of FreeSpec (KoTest)
, I can get the method name with this.testCase.name.testName
WIP.igor.wojda
09/18/2023, 9:29 AM.assert(suppressName = this.testCase.name.testName)
We will also add koTestName
extension, so final usage will be like this:
.assert(suppressName = koTestName)