From 53b7bdb4f9cbec324fb22dbc99e8fac074a141e3 Mon Sep 17 00:00:00 2001 From: Brad Wilson Date: Tue, 13 Aug 2024 08:48:09 -0700 Subject: [PATCH] Missing config load when running tests, discovered via xunit/xunit#3002 --- .../Utility/AssemblyRunInfo.cs | 10 +++++++++- src/xunit.runner.visualstudio/VsTestRunner.cs | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs b/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs index 9108620..40ed91d 100644 --- a/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs +++ b/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs @@ -8,6 +8,7 @@ namespace Xunit.Runner.VisualStudio; public class AssemblyRunInfo { AssemblyRunInfo( + LoggerHelper logger, XunitProject project, RunSettings runSettings, string assemblyFileName, @@ -18,8 +19,14 @@ public class AssemblyRunInfo Assembly = new XunitProjectAssembly(project, assemblyFileName, assemblyMetadata); TestCases = testCases; + var configWarnings = new List(); + ConfigReader.Load(Assembly.Configuration, Assembly.AssemblyFileName, Assembly.ConfigFileName, configWarnings); runSettings.CopyTo(Assembly.Configuration); + Assembly.Configuration.ExplicitOption = runExplicitTests ? ExplicitOption.On : ExplicitOption.Off; + + foreach (var warning in configWarnings) + logger.LogWarning("{0}", warning); } public XunitProjectAssembly Assembly { get; } @@ -27,6 +34,7 @@ public class AssemblyRunInfo public IList? TestCases { get; } public static AssemblyRunInfo? Create( + LoggerHelper logger, XunitProject project, RunSettings runSettings, string assemblyFileName, @@ -37,6 +45,6 @@ public class AssemblyRunInfo if (metadata is null || metadata.XunitVersion == 0) return null; - return new(project, runSettings, assemblyFileName, metadata, testCases, runExplicitTests); + return new(logger, project, runSettings, assemblyFileName, metadata, testCases, runExplicitTests); } } diff --git a/src/xunit.runner.visualstudio/VsTestRunner.cs b/src/xunit.runner.visualstudio/VsTestRunner.cs index d1e8109..0520b58 100644 --- a/src/xunit.runner.visualstudio/VsTestRunner.cs +++ b/src/xunit.runner.visualstudio/VsTestRunner.cs @@ -400,7 +400,7 @@ public void RunTests( () => tests .GroupBy(testCase => testCase.Source) - .Select(group => AssemblyRunInfo.Create(project, runSettings, group.Key, [.. group], runExplicitTests)) + .Select(group => AssemblyRunInfo.Create(logger, project, runSettings, group.Key, [.. group], runExplicitTests)) .WhereNotNull() .ToList() ).GetAwaiter().GetResult(); @@ -432,7 +432,7 @@ public void RunTests( // before returning from this function. RunTests( runContext, frameworkHandle, logger, testPlatformContext, runSettings, - () => sources.Select(source => AssemblyRunInfo.Create(project, runSettings, Path.GetFullPath(source))).WhereNotNull().ToList() + () => sources.Select(source => AssemblyRunInfo.Create(logger, project, runSettings, Path.GetFullPath(source))).WhereNotNull().ToList() ).GetAwaiter().GetResult(); }