Method ThrowsAny
- Namespace
- Xunit
- Assembly
- xunit.v3.assert.dll
ThrowsAny<T>(Action)
Verifies that the exact exception or a derived exception type is thrown.
public static T ThrowsAny<T>(Action testCode) where T : Exception
Parameters
testCodeActionA delegate to the code to be tested
Returns
- T
The exception that was thrown, when successful
Type Parameters
TThe type of the exception expected to be thrown
ThrowsAny<T>(Func<object?>)
Verifies that the exact exception or a derived exception type is thrown. Generally used to test property accessors.
public static T ThrowsAny<T>(Func<object?> testCode) where T : Exception
Parameters
Returns
- T
The exception that was thrown, when successful
Type Parameters
TThe type of the exception expected to be thrown