Repository navigation
Document that a single fixture instance is shared by parallel tests - #1278
SeanKilleen wants to merge 1 commit into
Conversation
The Parallelizable page warned about shared instance fields but never stated the underlying fact. Adds a "Fixture Instances and Parallel Tests" section explaining that NUnit creates one instance per fixture (per argument set for parameterized fixtures), constructed before `OneTimeSetUp` and disposed after `OneTimeTearDown`, that parallel execution does not create more instances, and that parallel test methods therefore share the same instance. Points to `FixtureLifeCycle` with `InstancePerTestCase` as the way to get per-test instances. Fixes #292 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
📖 Docs preview: https://pr-1278.nunit-docs.pages.dev Built from e23fcf5. This link always shows the latest build for this PR; the build for this exact commit is at https://9f0eb246.nunit-docs.pages.dev. Previews are hosted on Cloudflare Pages, are not indexed by search engines, and are removed when the PR is closed. They omit the archived NUnit 2.x documentation (the |
|
@OsirisTerje who is right person/group to review this? |
|
@SeanKilleen I think we send it to the @nunit/framework-team 😄 That said, it looks correct to me. |
|
|
||
| ## Fixture Instances and Parallel Tests | ||
|
|
||
| NUnit creates **one instance** of each test fixture class and reuses it for every test in that fixture. The instance is |
There was a problem hiding this comment.
Maybe mention the FixtureLifeCycle and LifeCycle.InstancePerTestCase
It does require static OneTimeSetUp so the sharing of things initialized there is similar.
The Parallelizable page warned about shared instance fields but never stated the underlying fact. Adds a "Fixture Instances and Parallel Tests" section explaining that NUnit creates one instance per fixture (per argument set for parameterized fixtures), constructed before
OneTimeSetUpand disposed afterOneTimeTearDown, that parallel execution does not create more instances, and that parallel test methods therefore share the same instance. Points toFixtureLifeCyclewithInstancePerTestCaseas the way to get per-test instances.Fixes #292
🤖 Generated with Claude Code