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

Eager Any.toString() in MatcherResult #2454

Closed
Tracked by #2226
PHaroZ opened this issue Sep 2, 2021 · 2 comments · Fixed by #2481
Closed
Tracked by #2226

Eager Any.toString() in MatcherResult #2454

PHaroZ opened this issue Sep 2, 2021 · 2 comments · Fixed by #2481
Labels
assertions 🔍 Related to the assertion mechanisms within the testing framework. bug 🐛 Issues that report a problem or error in the code.
Milestone

Comments

@PHaroZ
Copy link

PHaroZ commented Sep 2, 2021

kotest version 4.6.0

Hi,

Some of my tests deal with huge data class and I found that they are slow & memory consuming because a lots of matchers indirectly call Any.toString() even if those tests didn't return any error.

An exemple here :

return MatcherResult(passed, "Expected value to be null, but was $value.", "Expected value not be null, but was null.")

A simple workarround could be using
io.kotest.matchers.MatcherResult.Companion#invoke(boolean, kotlin.jvm.functions.Function0<java.lang.String>, kotlin.jvm.functions.Function0<java.lang.String>)
instead of
io.kotest.matchers.MatcherResult.Companion#invoke(boolean, java.lang.String, java.lang.String)

The linked example would look like

    return MatcherResult(passed, { "Expected value to be null, but was $value." }, { "Expected value not be null, but was null." })

I could make a PR if you do agree with me.

@sksamuel
Copy link
Member

sksamuel commented Sep 2, 2021

Definitely, good spot.

@sksamuel sksamuel added this to the 5.0 milestone Sep 2, 2021
@sksamuel sksamuel added assertions 🔍 Related to the assertion mechanisms within the testing framework. bug 🐛 Issues that report a problem or error in the code. labels Sep 2, 2021
@sksamuel sksamuel mentioned this issue Sep 2, 2021
71 tasks
@sksamuel
Copy link
Member

Fixed in master, will be in 5.0.0.M2

sksamuel added a commit that referenced this issue Sep 10, 2021
* Check all engine classes for internal prior to 5.0 release #2473

* Check all engine classes for internal prior to 5.0 release #2473

* Replaced eager matchers with lazy counterpart #2454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assertions 🔍 Related to the assertion mechanisms within the testing framework. bug 🐛 Issues that report a problem or error in the code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants