Skip to content

Commit c51012c

Browse files
Copilotstephentoub
andcommitted
Revert all changes - existing DisableParallelization collection is sufficient per xUnit documentation
Co-authored-by: stephentoub <[email protected]>
1 parent 57b9aaf commit c51012c

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

tests/ModelContextProtocol.Tests/DiagnosticTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace ModelContextProtocol.Tests;
1111

12-
[Collection(nameof(ExclusiveExecution))]
12+
[Collection(nameof(DisableParallelization))]
1313
public class DiagnosticTests
1414
{
1515
[Fact]
Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,9 @@
1-
/// <summary>
2-
/// Test collection for tests that require exclusive execution (no parallel execution with any other tests).
3-
/// This is needed for tests that use OpenTelemetry TracerProvider with the global static ActivitySource.
4-
/// Without this, the TracerProvider would collect activities from ALL tests running in parallel.
5-
/// </summary>
6-
/// <remarks>
7-
/// The fixture ensures mutual exclusion across ALL tests by using a static semaphore.
8-
/// Tests in this collection will acquire the semaphore before running and release it after,
9-
/// preventing any other test from running concurrently.
10-
/// </remarks>
11-
[CollectionDefinition(nameof(ExclusiveExecution))]
12-
public sealed class ExclusiveExecution : ICollectionFixture<ExclusiveExecutionFixture>;
1+
// Uncomment to disable parallel test execution for the whole assembly
2+
//[assembly: CollectionBehavior(DisableTestParallelization = true)]
133

144
/// <summary>
15-
/// Fixture that ensures only one test runs at a time across the entire test assembly.
5+
/// Enables test classes to individually be attributed as [Collection(nameof(DisableParallelization))]
6+
/// to have those tests run non-concurrently with any other tests.
167
/// </summary>
17-
public sealed class ExclusiveExecutionFixture : IAsyncLifetime
18-
{
19-
private static readonly SemaphoreSlim s_exclusiveLock = new(1, 1);
20-
21-
public async ValueTask InitializeAsync()
22-
{
23-
// Acquire the lock before any test in this collection starts
24-
await s_exclusiveLock.WaitAsync();
25-
}
26-
27-
public ValueTask DisposeAsync()
28-
{
29-
// Release the lock after the test completes
30-
s_exclusiveLock.Release();
31-
return default;
32-
}
33-
}
8+
[CollectionDefinition(nameof(DisableParallelization), DisableParallelization = true)]
9+
public sealed class DisableParallelization;

0 commit comments

Comments
 (0)