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

Simplify "should throw" #20

Closed
tpetricek opened this issue Oct 2, 2013 · 5 comments
Closed

Simplify "should throw" #20

tpetricek opened this issue Oct 2, 2013 · 5 comments

Comments

@tpetricek
Copy link
Member

Currently, you have to use ignore to discard the result in the function and you need to get type using typeof:

(fun () -> failwith "BOOM!" |> ignore) |> should throw typeof<System.Exception>

I think it would be neat if you could write just:

(fun () -> failwith "BOOM!") |> should throw<System.Exception>
@Evangelink
Copy link
Contributor

@sergey-tihon Do you care about retro compatibility? (i.e. should I keep the old method and create a new one?). I am about to do this quick PR.

@sergey-tihon
Copy link
Member

@Evangelink Yes we care about backward compatibility.
I think that we can support this feature in new FsUnit.Typed that is probably will be merged into FsUnit repo.

@Evangelink
Copy link
Contributor

Ok cheers! I will have a look.

@Evangelink
Copy link
Contributor

@sergey-tihon There is a shouldFail method line 36 (don't know how to link a portion of code) in your commit that already satisfy @tpetricek request.
(fun () -> failwith "BOOM!") |> shouldFail<exn>

Don't think it is worth doing a shouldThrow that will do the same thing (rename current method?). I can add a shouldFailWithMessage method that will also check the error message if wanted.

@sergey-tihon sergey-tihon added this to the Typed FsUnit milestone Feb 29, 2016
sergey-tihon added a commit to sergey-tihon/FsUnit that referenced this issue Mar 6, 2016
@sergey-tihon
Copy link
Member

Released in v2.2.0-beta1

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

No branches or pull requests

3 participants