A test with Understudy is an ordinary NUnit test: it declares spies, stubs and fakes, runs the code under test, and checks the result with NUnit constraints. For ready examples of what game code reaches most often, start with Test common Unity code; each of its examples links to the page that covers the feature in full.

Topics

TopicDescription
Test common Unity codeComponents, time, randomness, singletons, input, raycasts, events, coroutines, async code, logs, saves and scene loads.
Select a memberName the member a spy, stub or fake covers, for one instance or every instance, with argument matchers.
Stub membersReplace methods, constructors, fields, properties and indexers with the answers your test sets.
Check what the code under test didSpy on a member, and check what any spy, stub or fake recorded with NUnit constraints.
Fake fields and propertiesGive a field or property a stored value the code under test reads and writes instead of the real one.
Fake eventsReplace an event, raise it from the test, and check its handlers.
Run members for realDeclare that a member runs for real on purpose, over a stub or fake or for leak detection.
Spy on caught exceptionsCheck which exceptions the code under test catches, and what it does with them.
LifetimeWhen a spy, stub or fake starts and ends, and how each test starts it fresh.
Share doubles between testsGroup spies, stubs and fakes in a class of your own, and reuse it across tests and fixtures.

Additional resources