expekt
expekt copied to clipboard
Add exception expectation.
- It can use Closure and test exception.
-
raise
check exception type strictly.- It will fail when Closure does not throw expected exception.
-
raiseAny
check exception type not strictly.- It will fail when Closure does not throw any exception.
Example
passes
expect({ throw NullPointerException() }).raise(NullPointerException::class)
expect({ throw NullPointerException() }).raiseAny()
fails
expect({ /* nothing to thrown */ }).raise(NullPointerException::class)
expect({ throw CustomException() }).raise(NullPointerException::class)
#2
+1
+1
👍