xUnit 4 ParallelMode.All Requires Explicit Shared-State Guards to Prevent Test Races
xUnit.net v3 4.0.0 introduces full test-case parallelization via ParallelMode.All, allowing every test case — including theory rows within the same class — to run concurrently. Unlike the default ParallelMode.Collections, which serializes tests within a collection, the new mode must be explicitly opted into at the assembly level. This change can turn previously safe shared resources such as static fields, fixtures, fixed file names, or shared database records into race conditions. Developers are advised to audit mutable shared state before enabling the mode, using coordination primitives like barriers to reliably reproduce and confirm race risks. Thread-safe constructs such as Interlocked operations, locks, or concurrent collections should then be applied where concurrent access is required.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in