Closed
Description
Information about lifecycle doesn't seem to be documented. I think it can be summarized as follows.
- AssemblyInitialize is called, if present
- For every class:
- ClassInitialize is called, if present.
- For every test case in the class (a parameterized test method has its individual inputs as separate test cases):
- Create class instance (so your constructor is called, optionally, it can have TestContext parameter)
- Set TestContext property if present
- Run TestInitialize, including from base classes (base classes are called first in reverse order, then TestInitialize from the current class)
- Run the test method itself. If it returns a Task/ValueTask, we await it
- Update the test outcome in TestContext
- Run TestCleanup methods. First we run TestCleanup from the current class, then from any base classes in order (so it's reverse order of test initialize)
- If you implement IAsyncDisposable, we call DisposeAsync
- If you implement IDisposable, we call Dispose
- ClassCleanup is called, if present.
- AssemblyCleanup is called, if present.