Class UnityErrorLogInterceptor
Class used to replicate the Unity test runner behaviour of failing tests when either LogError(object) or LogException(Exception) is called.
Implements
Namespace: Responsible.Unity
Assembly: Responsible.dll
Syntax
public class UnityErrorLogInterceptor : IExternalResultSource
Methods
ExpectLog(LogType, Regex)
Expect a log message during execution of any subsequent test instructions. Similar to Expect(LogType, Regex), but needs to be called instead of that, in order to work when executing test instructions.
Declaration
public void ExpectLog(LogType logType, Regex regex)
Parameters
Type | Name | Description |
---|---|---|
LogType | logType | Log type to expect. |
Regex | regex | Regex to match the message to be expected. |
Remarks
Will call Expect(LogType, Regex), so it doesn't need to be called separately.
GetExternalResult<T>(CancellationToken)
Intercept errors, respecting and not toggling the globally mutable UnityEngine.TestTools.LogAssert.ignoreFailingMessages. Will complete with an error if either an error or exception is logged, and will never complete if neither of those happens.
Declaration
public Task<T> GetExternalResult<T>(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Token used to cancel this operation. |
Returns
Type | Description |
---|---|
Task<T> | Task, which will complete with an error if either an error or exception is logged. |
Type Parameters
Name | Description |
---|---|
T | Type of the test operation being run. |