Timeline for Assert an Exception using XUnit
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 27, 2023 at 15:00 | comment | added | vc 74 |
@ColinM I'm even later to the show but this approach allows to clearly distinguish between Act and Assert and to be able to assert on properties specific to the exception type (as opposed to those available on the Exception type)
|
|
Jul 21, 2022 at 13:23 | comment | added | DhyMik | Great solution if you need to assert an exception is thrown but you don't want to or can't be specific about the exception's type. | |
Mar 2, 2021 at 12:32 | comment | added | LosManos |
See other answer for how to use Record.ExceptionAsync for an async case.
|
|
Feb 20, 2020 at 21:06 | history | rollback | Bhargav Rao |
Rollback to Revision 1
|
|
Feb 20, 2020 at 20:15 | review | Low quality answers | |||
Feb 20, 2020 at 21:10 | |||||
Nov 22, 2019 at 9:22 | history | edited | user310988 | CC BY-SA 4.0 |
deleted 693 characters in body
|
Nov 21, 2019 at 18:26 | comment | added | ColinM |
@JeffLaFay I appreciate I'm a bit late to the party here, how would that differ from using var exception = Assert.Throws<InvalidOperationException>(testCode); and asserting on exception.Message ? or is it just another flavor of achieving the same thing?
|
|
Apr 9, 2019 at 16:10 | comment | added | Jeff LaFay | FWIW, This solution is great if you need to maybe validate the exception message, etc. I think that's when you might use Record.Exception. | |
May 15, 2018 at 10:09 | history | answered | user310988 | CC BY-SA 4.0 |