Class CodeCoverage
Utility class for the CodeCoverage api.
Namespace: UnityEditor.TestTools.CodeCoverage
Syntax
public static class CodeCoverage
Examples
The following example loads a scene, starts coverage recording, initialises a number of instances of a prefab, then pauses the recording to load another scene, unpauses the recording, initialises a number of instances of a different prefab and finally stops the recording.
using UnityEngine;
using UnityEditor;
using UnityEditor.TestTools.CodeCoverage;
using UnityEditor.SceneManagement;
public class CoverageApiTest : MonoBehaviour
{
[MenuItem("CodeCoverage/Run Recording")]
static void RunRecording()
{
int i;
EditorSceneManager.OpenScene("Assets/Scenes/Scene1.unity");
CodeCoverage.StartRecording();
for (i = 0; i < 1000; ++i)
{
Instantiate(Resources.Load("ComplexPrefab1"));
}
CodeCoverage.PauseRecording();
EditorSceneManager.OpenScene("Assets/Scenes/Scene2.unity");
CodeCoverage.UnpauseRecording();
for (i = 0; i < 1000; ++i)
{
Instantiate(Resources.Load("ComplexPrefab2"));
}
CodeCoverage.StopRecording();
}
}
Methods
PauseRecording()
Call this to pause the recording on the current coverage recording session.
Declaration
public static void PauseRecording()
StartRecording()
Call this to start a new coverage recording session.
Declaration
public static void StartRecording()
StopRecording()
Call this to end the current coverage recording session.
Declaration
public static void StopRecording()
UnpauseRecording()
Call this to continue recording on the current coverage recording session, after having paused the recording.
Declaration
public static void UnpauseRecording()