Skip to content

No way to validate thrown exceptions #12

Description

@C06A

It seams that framwork doesn't provide any way to check that tested code throws exception of specific kind. I guess test code can use try/catch, do fail if rich the end of try and do assertions in the catch clause. However this seams clunky and won't give correct nice message in case of failure.

I think the syntax for exceptions could be: expect(MyException::class).thrownBy {...}
If thrownBy returns the exception following code can validate details about it (message, cause, etc.).

Alternative syntax may be expect {...}.throws(MyException::class).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions