XUnit doesn't natively expose an obvious way to run global setup code before all tests. By creating a class that extends XunitTestFramework and decorating the assembly with the [assembly: TestFramework(...)] attribute, you can execute synchronous setup logic once before test discovery begins. A practical example shows how to set OaktonEnvironment.AutoStartHost = true for projects using the Oakton command-line library. The post warns that this approach is only suitable for lightweight global settings — not database initialization or async work — and that it runs during IDE test discovery, which can affect test isolation.

3m read timeFrom event-driven.io
Post cover image