Skip to content

Commit

Permalink
Add aggressive display to TestFrameworkEnvironment reported by XunitT…
Browse files Browse the repository at this point in the history
…estAssemblyRunner
  • Loading branch information
bradwilson committed Apr 20, 2024
1 parent 3dd7e91 commit 6790b48
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Expand Up @@ -59,13 +59,20 @@ protected override string GetTestFrameworkEnvironment()

var testCollectionFactory = ExtensibilityPointFactory.GetXunitTestCollectionFactory(DiagnosticMessageSink, collectionBehaviorAttribute, TestAssembly);
var threadCountText = maxParallelThreads < 0 ? "unlimited" : maxParallelThreads.ToString(CultureInfo.CurrentCulture);
threadCountText += " thread";
if (maxParallelThreads != 1)
threadCountText += 's';
if (parallelAlgorithm == ParallelAlgorithm.Aggressive)
threadCountText += "/aggressive";

return string.Format(
CultureInfo.CurrentCulture,
"{0} [{1}, {2}]",
base.GetTestFrameworkEnvironment(),
testCollectionFactory.DisplayName,
disableParallelization ? "non-parallel" : string.Format(CultureInfo.CurrentCulture, "parallel ({0} threads)", threadCountText)
disableParallelization
? "non-parallel"
: string.Format(CultureInfo.CurrentCulture, "parallel ({0})", threadCountText)
);
}

Expand Down
Expand Up @@ -136,6 +136,19 @@ public static void TestOptions_MaxThreads()
Assert.EndsWith("[collection-per-class, parallel (3 threads)]", result);
}

[Fact]
public static void TestOptions_MaxThreads_Aggressive()
{
var options = TestFrameworkOptions.ForExecution();
options.SetMaxParallelThreads(3);
options.SetParallelAlgorithm(ParallelAlgorithm.Aggressive);
var runner = TestableXunitTestAssemblyRunner.Create(executionOptions: options);

var result = runner.GetTestFrameworkEnvironment();

Assert.EndsWith("[collection-per-class, parallel (3 threads/aggressive)]", result);
}

[Fact]
public static void TestOptions_Unlimited()
{
Expand Down

0 comments on commit 6790b48

Please sign in to comment.