Problem
[Timeout] currently only applies to test body execution. Hooks and object initializers have no timeout protection — a misbehaving [Before(HookType.Assembly)] or IAsyncInitializer.InitializeAsync() that hangs will block the entire test run indefinitely.
Goal
Make [Timeout] much more powerful — it should be applicable to:
- Test body (current behavior)
- Hooks —
[Before] / [After] at all scopes (Test, Class, Assembly, Session, Discovery)
- Object initializers —
IAsyncInitializer.InitializeAsync() implementations
- Broader scopes — e.g.
[Timeout] on an assembly meaning "the entire test run must complete within X"
Design Questions
- How does
[Timeout] on a class interact with [Timeout] on individual tests? Is it a total budget for the class, or a default for each test?
- Assembly-level
[Timeout] — is it a hard cap on the entire assembly's execution time? What happens to in-flight tests when it fires?
- Hook timeouts — should they inherit from the scope they belong to (e.g. a class-level hook inherits the class timeout), or require explicit configuration?
- Should individual hooks be able to opt out of a scope-level timeout?
- How does this interact with
[Retry]? Does each retry get a fresh timeout, or does the timeout cover all retries?
- Object initializer timeouts — should they be separate from the test timeout, or part of it? (Currently data source init runs outside the test timeout)
Notes
- Requires careful design before implementation
- Some aspects may be breaking (changing what
[Timeout] on a class means)
- Deferred to v2
Problem
[Timeout]currently only applies to test body execution. Hooks and object initializers have no timeout protection — a misbehaving[Before(HookType.Assembly)]orIAsyncInitializer.InitializeAsync()that hangs will block the entire test run indefinitely.Goal
Make
[Timeout]much more powerful — it should be applicable to:[Before]/[After]at all scopes (Test, Class, Assembly, Session, Discovery)IAsyncInitializer.InitializeAsync()implementations[Timeout]on an assembly meaning "the entire test run must complete within X"Design Questions
[Timeout]on a class interact with[Timeout]on individual tests? Is it a total budget for the class, or a default for each test?[Timeout]— is it a hard cap on the entire assembly's execution time? What happens to in-flight tests when it fires?[Retry]? Does each retry get a fresh timeout, or does the timeout cover all retries?Notes
[Timeout]on a class means)