A TestInstructionExecutor implementation that should work well in Unity:
- Polls on every frame
- Causes test operations to fail on logged errors
- Can also log failures, as Unity will swallow exceptions in nested coroutines
public class UnityTestInstructionExecutor : TestInstructionExecutor, IDisposable
Remember to dispose all instances of this class which you create!
Constructs a new TestInstructionExecutor with a default Unity configuration. If you are not using Responsible all the way, but also have some bare coroutines involved, you will probably want to also log any errors, in addition to failing the tests the normal way, as Unity has the tendency to swallow exceptions from nested coroutines.
public UnityTestInstructionExecutor(bool logErrors = true, IGlobalContextProvider globalContextProvider = null)
Whether or not errors should be logged in addition to propagated.
Optional provider for global context, which gets included in failure messages.
Disposes this executor, so that no more polling or log intercepting is done.
public override void Dispose()
Similar to UnityEngine.TestTools.LogAssert.Expect(UnityEngine.LogType,System.Text.RegularExpressions.Regex), but must be used instead of that, for Responsible to be able to successfully ignore errors. See also UnityErrorLogInterceptor. UnityEngine.TestTools.LogAssert.ignoreFailingMessages is respected
public void ExpectLog(LogType logType, Regex regex)
Log type to expect
Regular expression to match in the expected message