Table of Contents

Method RecordException

Namespace
Xunit
Assembly
xunit.v3.assert.dll

RecordException(Action)

Records any exception which is thrown by the given code.

protected static Exception? RecordException(Action testCode)

Parameters

testCode Action

The code which may thrown an exception.

Returns

Exception

Returns the exception that was thrown by the code; null, otherwise.

RecordException(Func<object?>, string)

Records any exception which is thrown by the given code that has a return value. Generally used for testing property accessors.

protected static Exception? RecordException(Func<object?> testCode, string asyncMethodName)

Parameters

testCode Func<object>

The code which may thrown an exception.

asyncMethodName string

The name of the async method the user should've called if they accidentally passed in an async function

Returns

Exception

Returns the exception that was thrown by the code; null, otherwise.