question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Result4k Kotest Matchers

See original GitHub issue

Hello there. I’ve recently decided to migrate one of my projects from Arrow to Result4k as all I really need is a Result type. The one thing I miss though are Kotest matchers like shouldBeInvalid, shouldBeValid, shouldBeLeft etc. and I couldn’t find anything out of the box for Result4k!

Would this project be interested in a Kotest module? I’ve made a draft one here under the Result4k folder which provides various shouldBeSuccess and shouldBeFailure functions, usage looks like:

fun exampleDivideByZero() {
    val result = divide(5, 0) //function that returns Failure upon divide by zero

    //all of these would pass
    result.shouldBeFailure()
    result shouldBeFailure DivideByZeroFailure
    result shouldBeFailure { reason ->
        reason shouldBe DivideByZeroFailure
    }

    //but this will fail with the appropriate message
    result shouldBeSuccess 5 //Throws AssertionError like: Failure(DivideByZero) should be Success(5)
}

If you’d rather keep stuff like this out of this repo I’d be happy to just maintain this in a separate repo as it’s pretty small in scope 😅

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MrBergincommented, Mar 21, 2021

Ah I thought that might be the case! Will keep you posted.

0reactions
daviddentoncommented, Jun 10, 2021

Cool. We’ll put it into the readme. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kotest matchers for the Result4k library - GitHub
Kotest matchers for the Result4k library. Contribute to MrBergin/result4k-kotest-matchers development by creating an account on GitHub.
Read more >
Matchers - Kotest
A Matcher is the Kotest term for an assertion that performs a specific test. For example, a matcher may test that a double...
Read more >
result4k-kotest-matchers vs http4k-connect - compare differences ...
Compare result4k-kotest-matchers vs http4k-connect and see what are their differences. ... Kotest matchers for the Result4k library (by MrBergin).
Read more >
result4k-kotest-matchers Java documentation Version 0.0.4
Javadoc for the artifact result4k-kotest-matchers from the group dev.mrbergin version 0.0.4.
Read more >
Use io.kotest.matchers.uri.matchers in Kotest With Examples ...
Learn how to use matchers class in io.kotest.matchers.uri package for your next Kotest project ... shouldBeFailure 5import dev.mrbergin.kotest.result4k.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found