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

Add exception expectation. #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

saku
Copy link

@saku saku commented Dec 17, 2016

  • 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

Update README text also.
@VerachadW
Copy link

+1

@lucasluiz
Copy link

+1

@joshskeen
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants