Skip to content

Commit

Permalink
Add RunSettings: Explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Oct 16, 2024
1 parent 522c078 commit 15da70f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public class AssemblyRunInfo
ConfigReader.Load(Assembly.Configuration, Assembly.AssemblyFileName, Assembly.ConfigFileName, configWarnings);
runSettings.CopyTo(Assembly.Configuration);

Assembly.Configuration.ExplicitOption = runExplicitTests ? ExplicitOption.On : ExplicitOption.Off;
// The Test Explorer UI doesn't give the user the ability to specify this, so if we haven't come along
// and set it via the command line, we'll use our auto-calculation based on what we think the user wants
Assembly.Configuration.ExplicitOption ??= runExplicitTests ? ExplicitOption.On : ExplicitOption.Off;

foreach (var warning in configWarnings)
logger.LogWarning("{0}", warning);
Expand Down
8 changes: 8 additions & 0 deletions src/xunit.runner.visualstudio/Utility/RunSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class RunSettings
public string? Culture { get; set; }
public bool DesignMode { get; set; } = false;
public bool? DiagnosticMessages { get; set; }
public ExplicitOption? Explicit { get; set; }
public bool? FailSkips { get; set; }
public bool? FailWarns { get; set; }
public bool? InternalDiagnosticMessages { get; set; }
Expand Down Expand Up @@ -44,6 +45,8 @@ public void CopyTo(TestAssemblyConfiguration configuration)
};
if (DiagnosticMessages.HasValue)
configuration.DiagnosticMessages = DiagnosticMessages;
if (Explicit.HasValue)
configuration.ExplicitOption = Explicit;
if (FailSkips.HasValue)
configuration.FailSkips = FailSkips;
if (FailWarns.HasValue)
Expand Down Expand Up @@ -102,6 +105,10 @@ public static RunSettings Parse(string? settingsXml)
if (bool.TryParse(diagnosticMessagesString, out var diagnosticMessages))
result.DiagnosticMessages = diagnosticMessages;

var explicitString = xunitElement.Element(Constants.Xunit.Explicit)?.Value;
if (Enum.TryParse<ExplicitOption>(explicitString, ignoreCase: true, out var @explicit))
result.Explicit = @explicit;

var failSkipsString = xunitElement.Element(Constants.Xunit.FailSkips)?.Value;
if (bool.TryParse(failSkipsString, out var failSkips))
result.FailSkips = failSkips;
Expand Down Expand Up @@ -258,6 +265,7 @@ public static class Xunit
public const string AppDomain = nameof(AppDomain);
public const string Culture = nameof(Culture);
public const string DiagnosticMessages = nameof(DiagnosticMessages);
public const string Explicit = nameof(Explicit);
public const string FailSkips = nameof(FailSkips);
public const string FailWarns = nameof(FailWarns);
public const string InternalDiagnosticMessages = nameof(InternalDiagnosticMessages);
Expand Down

0 comments on commit 15da70f

Please sign in to comment.