Execution order of test actions
Understand the order in which test actions run relative to one another.
Read time 1 minuteLast updated 22 days ago
When writing tests, it is possible to avoid duplication of code by using the SetUp and TearDown methods built into NUnit. The Unity Test Framework has extended these methods with extra functionality, which can yield commands and skip frames, in the same way as .
UnityTestAction execution order
The actions related to a test run in the following order:
- Attributes implementing IApplyToContext
- Methods marked with .
[UnityOneTimeSetUp] - Methods marked with .
[OneTimeSetup] - The method of any attribute implementing IOuterUnityTestAction.
BeforeTest - Methods marked with .
[UnitySetUp] - Attributes implementing IWrapSetUpTearDown.
- Methods marked with .
[SetUp] - The method of Action attributes.
BeforeTest - Attributes implementing IWrapTestMethod.
- The test itself runs
- The method of Action attributes.
AfterTest - Methods marked with .
[TearDown] - Methods marked with .
[UnityTearDown] - The method of any attribute implementing IOuterUnityTestAction.
AfterTest - Methods marked with .
[OneTimeTearDown] - Methods marked with .
[UnityOneTimeTearDown]
The list of actions is the same for both and .
TestUnityTestExecution order flow

The order of execution for test actions and callbacks, with those that re-run on domain reload differentiated from those that don't.