It’s also not possible to call `assert` on a singl...
# konsist
m
It’s also not possible to call
assert
on a single declaration, only on a list of them. This is forcing me to not use assert when I have only one declaration and instead use assertions from the unit testing library - losing the useful error messages that Konsist provides.
Workaround is to just add:
Copy code
fun <E : KoBaseProvider> E.assert(function: (E) -> Boolean?) {
    listOf(this).assert(function)
}
i
I am concreting this - please post concrete example where you this this is useful
m
Screenshot 2023-09-14 at 13.51.55.png
For example I could be generating test cases per ViewModel and then each test case already has a single KoClassDeclaration instance to work on.
i
This feature has been added to new version of Konsist (just released 0.12.0) Thanks for the contribution 🙏 BTW it is great to see how Konsist is used with koTest - we will try to refine this over time
BTW I have just found a bug where "single declaration assert" does not work with all declarations, will be fixed in next release
Due to small oversight this was not released. Please stick to youe extension for now. This change will be released with
v0.13.0
👍 1