Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rel/3.8] Fix parallelism:enabled incorrectly setting OrderTestsByNameInClass #5114

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Adapter/MSTest.TestAdapter/MSTestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ internal static void SetSettingsFromConfig(IConfiguration configuration, IMessag

ParseBooleanSetting(configuration, "output:captureTrace", logger, value => settings.CaptureDebugTraces = value);

ParseBooleanSetting(configuration, "parallelism:enabled", logger, value => settings.OrderTestsByNameInClass = value);
ParseBooleanSetting(configuration, "parallelism:enabled", logger, value => settings.DisableParallelization = !value);

ParseBooleanSetting(configuration, "execution:mapInconclusiveToFailed", logger, value => settings.MapInconclusiveToFailed = value);
ParseBooleanSetting(configuration, "execution:mapNotRunnableToFailed", logger, value => settings.MapNotRunnableToFailed = value);
Expand Down
77 changes: 52 additions & 25 deletions test/UnitTests/MSTestAdapter.UnitTests/MSTestSettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.TestableImplementations;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Moq;

Expand Down Expand Up @@ -1310,33 +1309,32 @@ public void ConfigJson_WithInvalidValues_GettingAWarningForEachInvalidSetting()
_mockMessageLogger.Verify(lm => lm.SendMessage(TestMessageLevel.Warning, "Invalid value '3' for runsettings entry 'execution:considerFixturesAsSpecialTests', setting will be ignored."), Times.Once);
}

[TestMethod]
public void ConfigJson_WithValidValues_ValuesAreSetCorrectly()
{
// Arrange - setting up valid configuration values
var configDictionary = new Dictionary<string, string>
{
{ "mstest:timeout:assemblyInitialize", "300" },
{ "mstest:timeout:assemblyCleanup", "300" },
{ "mstest:timeout:classInitialize", "200" },
{ "mstest:timeout:classCleanup", "200" },
{ "mstest:timeout:testInitialize", "100" },
{ "mstest:timeout:testCleanup", "100" },
{ "mstest:timeout:test", "60" },
{ "mstest:timeout:useCooperativeCancellation", "true" },
{ "mstest:parallelism:enabled", "true" },
{ "mstest:parallelism:workers", "4" },
{ "mstest:parallelism:scope", "class" },
{ "mstest:execution:mapInconclusiveToFailed", "true" },
{ "mstest:execution:mapNotRunnableToFailed", "true" },
{ "mstest:execution:treatDiscoveryWarningsAsErrors", "true" },
{ "mstest:execution:considerEmptyDataSourceAsInconclusive", "true" },
{ "mstest:execution:treatClassAndAssemblyCleanupWarningsAsErrors", "true" },
{ "mstest:execution:considerFixturesAsSpecialTests", "true" },
{ "mstest:enableBaseClassTestMethodsFromOtherAssemblies", "true" },
{ "mstest:orderTestsByNameInClass", "true" },
{ "mstest:output:captureTrace", "true" },
};
{
{ "mstest:timeout:assemblyInitialize", "300" },
{ "mstest:timeout:assemblyCleanup", "300" },
{ "mstest:timeout:classInitialize", "200" },
{ "mstest:timeout:classCleanup", "200" },
{ "mstest:timeout:testInitialize", "100" },
{ "mstest:timeout:testCleanup", "100" },
{ "mstest:timeout:test", "60" },
{ "mstest:timeout:useCooperativeCancellation", "true" },
{ "mstest:parallelism:enabled", "true" },
{ "mstest:parallelism:workers", "4" },
{ "mstest:parallelism:scope", "class" },
{ "mstest:execution:mapInconclusiveToFailed", "true" },
{ "mstest:execution:mapNotRunnableToFailed", "true" },
{ "mstest:execution:treatDiscoveryWarningsAsErrors", "true" },
{ "mstest:execution:considerEmptyDataSourceAsInconclusive", "true" },
{ "mstest:execution:treatClassAndAssemblyCleanupWarningsAsErrors", "true" },
{ "mstest:execution:considerFixturesAsSpecialTests", "true" },
{ "mstest:enableBaseClassTestMethodsFromOtherAssemblies", "true" },
{ "mstest:orderTestsByNameInClass", "true" },
{ "mstest:output:captureTrace", "true" },
};

var mockConfig = new Mock<IConfiguration>();
mockConfig.Setup(config => config[It.IsAny<string>()])
Expand Down Expand Up @@ -1367,11 +1365,40 @@ public void ConfigJson_WithValidValues_ValuesAreSetCorrectly()
Verify(settings.TestInitializeTimeout == 100);
Verify(settings.TestCleanupTimeout == 100);

Verify(!settings.DisableParallelization);
Verify(settings.ParallelizationWorkers == 4);
Verify(settings.ParallelizationScope == ExecutionScope.ClassLevel);
}

public void ConfigJson_Parllelism_Enabled_True() => ConfigJson_Parllelism_Enabled_Core(true);

public void ConfigJson_Parllelism_Enabled_False() => ConfigJson_Parllelism_Enabled_Core(false);

private void ConfigJson_Parllelism_Enabled_Core(bool parallelismEnabled)
{
// Arrange - setting up valid configuration values
var configDictionary = new Dictionary<string, string>
{
{ "mstest:parallelism:enabled", parallelismEnabled.ToString().ToLowerInvariant() },
{ "mstest:parallelism:workers", "4" },
{ "mstest:parallelism:scope", "class" },
};

var mockConfig = new Mock<IConfiguration>();
mockConfig.Setup(config => config[It.IsAny<string>()])
.Returns((string key) => configDictionary.TryGetValue(key, out string value) ? value : null);

var settings = new MSTestSettings();

// Act
MSTestSettings.SetSettingsFromConfig(mockConfig.Object, _mockMessageLogger.Object, settings);

// Assert
Verify(settings.DisableParallelization == !parallelismEnabled);
Verify(settings.ParallelizationWorkers == 4);
Verify(settings.ParallelizationScope == ExecutionScope.ClassLevel);
}

[TestMethod]
public void ConfigJson_WithValidValues_MethodScope()
{
// Arrange - setting up valid configuration values
Expand Down
Loading