Retrieve test results
Register to receive callbacks from the test runner at the start or finish of an active test run or individual test.
Read time 1 minuteLast updated 14 days ago
You can receive callbacks when the active test run, or individual tests, starts and finishes. You can register callbacks by invoking on the with an instance of a class that implements . There are four methods for the start and finish of both the whole run and each level of the test tree.
RegisterCallbacksTestRunnerApiICallbacksICallbacksThe folliwng example shows how listeners can be set up:
public void SetupListeners(){ var api = ScriptableObject.CreateInstance<TestRunnerApi>(); api.RegisterCallbacks(new MyCallbacks());}private class MyCallbacks : ICallbacks{ public void RunStarted(ITestAdaptor testsToRun) { } public void RunFinished(ITestResultAdaptor result) { } public void TestStarted(ITestAdaptor test) { } public void TestFinished(ITestResultAdaptor result) { if (!result.HasChildren && result.ResultState != "Passed") { Debug.Log(string.Format("Test {0} {1}", result.Test.Name, result.ResultState)); } }}
It is possible to provide a as an integer as the second argument when registering a callback. This influences the invocation order of different callbacks. The default value is zero. It is also possible to provide with a class instance that implements that is an extended version of . also has a callback method for that invokes if the run fails to start, for example, due to compilation errors or if an IPrebuildSetup throws an exception.
priorityRegisterCallbacksIErrorCallbacksICallbacksIErrorCallbacksOnError