Riccardo Cardin
10/27/2023, 11:56 AMassertj-arrow-core
library 🚀 . If you want the complete list of changes, check it out here. This version makes a new list of RaiseE 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!
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:
context (Raise<String>)
fun aFunctionThatRaisesAnError(): Int = raise("LOGICAL ERROR")
@Test
internal fun `should pass if lambda raises a logical error`() {
assertThat { aFunctionThatRaisesAnError() }.raises("LOGICAL ERROR")
}
Happy coding! 🎉