-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Run classes in parallel if they are in a single collection (#17)
* Run classes in parallel if they are in a single collection * Don't break default behavior * Bump version to 2.3.0 * Fix release build * Update Analyzer to 2.0.162 --------- Co-authored-by: Preben Huybrechts <[email protected]>
- Loading branch information
Showing
8 changed files
with
155 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Meziantou.Xunit.ParallelTestFramework.Tests/CollectionConcurrencyFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Meziantou.Xunit.ParallelTestFramework.Tests; | ||
|
||
public class CollectionConcurrencyFixture | ||
{ | ||
private int concurrency; | ||
|
||
public async Task<int> CheckConcurrencyAsync() | ||
{ | ||
Interlocked.Increment(ref concurrency); | ||
await Task.Delay(TimeSpan.FromMilliseconds(1000)).ConfigureAwait(false); | ||
|
||
var overlap = concurrency; | ||
|
||
await Task.Delay(TimeSpan.FromMilliseconds(1000)).ConfigureAwait(false); | ||
Interlocked.Decrement(ref concurrency); | ||
|
||
return overlap; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Meziantou.Xunit.ParallelTestFramework.Tests/ParallelCollectionMultiClass1AttributeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Xunit; | ||
|
||
namespace Meziantou.Xunit.ParallelTestFramework.Tests; | ||
|
||
[Collection("ParallelMultiClass")] | ||
public class ParallelCollectionMultiClass1AttributeTests | ||
{ | ||
private readonly CollectionConcurrencyFixture fixture; | ||
|
||
public ParallelCollectionMultiClass1AttributeTests(CollectionConcurrencyFixture fixture) | ||
{ | ||
this.fixture = fixture; | ||
} | ||
|
||
[Fact] | ||
public async Task Fact1() | ||
{ | ||
Assert.Equal(2, await fixture.CheckConcurrencyAsync().ConfigureAwait(false)); | ||
} | ||
|
||
[Fact] | ||
public async Task Fact2() | ||
{ | ||
Assert.Equal(2, await fixture.CheckConcurrencyAsync().ConfigureAwait(false)); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Meziantou.Xunit.ParallelTestFramework.Tests/ParallelCollectionMultiClass2AttributeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Xunit; | ||
|
||
namespace Meziantou.Xunit.ParallelTestFramework.Tests; | ||
|
||
[Collection("ParallelMultiClass")] | ||
public class ParallelCollectionMultiClass2AttributeTests | ||
{ | ||
private readonly CollectionConcurrencyFixture fixture; | ||
|
||
public ParallelCollectionMultiClass2AttributeTests(CollectionConcurrencyFixture fixture) | ||
{ | ||
this.fixture = fixture; | ||
} | ||
|
||
[Fact] | ||
public async Task Fact1() | ||
{ | ||
Assert.Equal(2, await fixture.CheckConcurrencyAsync().ConfigureAwait(false)); | ||
} | ||
|
||
[Fact] | ||
public async Task Fact2() | ||
{ | ||
Assert.Equal(2, await fixture.CheckConcurrencyAsync().ConfigureAwait(false)); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Meziantou.Xunit.ParallelTestFramework.Tests/ParallelMultiClassCollectionFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Xunit; | ||
|
||
namespace Meziantou.Xunit.ParallelTestFramework.Tests; | ||
|
||
[CollectionDefinition("ParallelMultiClass")] | ||
[EnableParallelization] | ||
public class ParallelMultiClassCollectionFixture : ICollectionFixture<CollectionConcurrencyFixture> | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters