@@ -57,6 +57,7 @@ due to their level of complexity.
5757 * AnimatorPlayback objects to easily detect animation completion conditions
5858 * Pre-built library on AnimatorBehavior(s) for complex animation playback
5959 * Animator extensions that add missing functionality to Unity's Animator component
60+ * Animator unit testing helper (for editor only tests)
6061 * Unit tested
6162
6263#### Requesting Features
@@ -125,3 +126,42 @@ call per unique `AnimatorController`. While this generally shouldn't cause perfo
125126You may need to call ` AnimatorHelperRuntime.Instance.Cache(Animator) ` on ` Start ` or ` Awake ` if your ` Animator(s) `
126127have over 300 parameters. Please note that your ` AnimatorController ` object (what you pass into the Animator via
127128inspector) must be uniquely named in order for the caching to work correctly.
129+
130+ ## Animator Unit Test Helper
131+
132+ This library provides an ` AnimatorStub ` (editor only) class that makes testing animations via pure code super simple.
133+ All you need to do is the following.
134+
135+ ``` c#
136+ using Adnc .AnimatorHelpers .Editors .Testing .Utilities ;
137+ using NUnit .Framework ;
138+ using UnityEngine ;
139+
140+ public class TestAnimatorStub {
141+ private AnimatorStub _stub ;
142+
143+ [SetUp ]
144+ public void Setup () {
145+ _stub = new AnimatorStub ();
146+ }
147+
148+ [TearDown ]
149+ public void Teardown () {
150+ // The stub is attached to a GameObject, so it must be destroyed manually
151+ Object .DestroyImmediate (_stub .Animator .gameObject );
152+ }
153+
154+ [Test ]
155+ public void MyTest () {
156+ // Setup your AnimatorController as desired
157+ stub .AnimatorCtrl .AddParameter (" myBool" , AnimatorControllerParameterType .Bool );
158+
159+ // Inject a runtime version of the AnimatorController with all of your settings
160+ stub .InjectCtrl ();
161+
162+ // Test as normal
163+ // stub.Animator.Update(10); // If you need to simulate time
164+ Assert .IsTrue (stub .Animator .HasBool (" myBool));
165+ }
166+ }
167+ ```
0 commit comments