Skip to content

Commit

Permalink
Missing config load when running tests, discovered via xunit/xunit#3002
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Aug 13, 2024
1 parent feef548 commit 53b7bdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Xunit.Runner.VisualStudio;
public class AssemblyRunInfo
{
AssemblyRunInfo(
LoggerHelper logger,
XunitProject project,
RunSettings runSettings,
string assemblyFileName,
Expand All @@ -18,15 +19,22 @@ public class AssemblyRunInfo
Assembly = new XunitProjectAssembly(project, assemblyFileName, assemblyMetadata);
TestCases = testCases;

var configWarnings = new List<string>();
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; }

public IList<TestCase>? TestCases { get; }

public static AssemblyRunInfo? Create(
LoggerHelper logger,
XunitProject project,
RunSettings runSettings,
string assemblyFileName,
Expand All @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/xunit.runner.visualstudio/VsTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 53b7bdb

Please sign in to comment.