https://kotlinlang.org logo
#feed
Title
# feed
r

Riccardo Cardin

10/27/2023, 12:01 PM
Hey, arrow fans. I released version 0.2.0 of the
assertj-arrow-core
library 🚀 . If you want the complete list of changes, check it out here. This version makes a new list of Raise<E> assertions available 😍 . Say that you have a function in the
Raise<E>
context and want to know if it succeeded with a specific value. Nothing easier!
Copy code
context (Raise<String>)
fun aFunctionWithContext(input: Int): Int = input

@Test
internal fun `should pass if lambda succeeds with the given value`() {
    assertThat { aFunctionWithContext(42) }.succeedsWith(42)
}
Same thing if you want to check if the function fails with an specific error:
Copy code
context (Raise<String>)
fun aFunctionThatRaisesAnError(): Int = raise("LOGICAL ERROR")

@Test
internal fun `should pass if lambda raises a logical error`() {
    assertThat { Dummy.aFunctionThatRaisesAnError() }.raises("LOGICAL ERROR")
}
Happy coding! 🎉