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

Kotest assertions support #65

Closed
sergeidyga opened this issue Jun 1, 2022 · 3 comments
Closed

Kotest assertions support #65

sergeidyga opened this issue Jun 1, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@sergeidyga
Copy link

Hi! Thanks for the awesome plugin!

Is Kotest assertions support planned somewhere in the future?

@bnorm
Copy link
Owner

bnorm commented Jun 1, 2022

Hello! I don't use Kotest so support for its assertions hasn't been on my radar. kotlin-power-assert can support any function call which allows passing a String to the last parameter, so support may already exist. But again, I'm not familiar with Kotest enough to say for sure.

Stepping back from the original question a bit: what's the end goal? If Kotest isn't providing enough diagnostic information when an assertion fails, that seems like an issue with Kotest. And one of the primary goals of this compiler plugin is to avoid needing a complex assertion library in the first place. Ultimately I'm curious to know your use case for combining these 2 libraries and what benefits you think kotlin-power-assert will add.

@sschuberth
Copy link

If I may chime in here as another Kotest user: Currently, Kotest's output when asserting equality of data classes (which may contain other data classes) is quite limited. Basically, it just asserts that the toString() representations of the classes are equal. As a result, the message for a failed assertion is long an rather non-telling.

So it would be nice to be able to leverage kotlin-power-assert for writing a Kotest matcher that is able to print some nice diagram about the differences in a hierarchy of nested data classes. In particular, equal data classes in the hierarchy should be skipped to not clutter the assertion output with unnecessary stuff.

@bnorm
Copy link
Owner

bnorm commented Mar 22, 2024

Functions with receivers (infix or not) are supported (#68), so all Kotest would need to do is add overloads which also take a string as the last parameter. Then kotlin-power-assert could transform Kotest assertions. See the tests here for an example. Explicit support of Kotest is not within the scope of this plugin, so closing as "not planned".

As for the data class example, I think that falls under #76, as we could diff data classes intelligently if we new their equals function wasn't custom.

@bnorm bnorm closed this as not planned Won't fix, can't repro, duplicate, stale Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants