test: enable MapManager unit test discovery#3
Conversation
There was a problem hiding this comment.
Pull request overview
Enables reliable discovery and execution of MapManager.UnitTests in CI (VSTest-based gates) by marking the project as a test project, adding the VS test adapter, and making config-path assertions portable across machines/framework output paths.
Changes:
- Mark
MapManager.UnitTestsas a test project and add thexunit.runner.visualstudioadapter. - Copy
Default/Sharedfixture content into build output for tests. - Replace hard-coded absolute path assertions in
ConfigTestwith output-relative paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| MapManager.UnitTests/MapManager.UnitTests.csproj | Enables VSTest discovery and stages fixture content into output. |
| MapManager.UnitTests/Apis/Config/ConfigTest.cs | Makes config path assertions portable by deriving expected paths dynamically. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| using MapManager.Apis; | ||
| using Serilog; | ||
| using Serilog.Events; | ||
| using System.IO; | ||
| using Xunit; |
| <Content Include="..\Default\**" Link="Default\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" /> | ||
| <Content Include="..\MapManager\Shared\**" Link="Shared\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" /> |
| <PackageReference Include="xunit.v3" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" /> |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19345b0afb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <PackageReference Include="Serilog" /> | ||
| <PackageReference Include="Serilog.Sinks.XUnit3" /> | ||
| <PackageReference Include="xunit.v3" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" /> |
There was a problem hiding this comment.
Pin the xUnit adapter to a v3-capable version
When this project is restored without central package versions (there is no Directory.Packages.props in the repo), this versionless PackageReference does not mean “latest”; NuGet restores the lowest available version for an unbounded dependency (NU1604 docs). The xUnit v3 docs require xunit.runner.visualstudio 3.0+ for v3 support (xUnit package docs), so a clean restore can select a 2.x adapter and dotnet test/Test Explorer still won't discover the xunit.v3 tests. Please pin this package to >= 3.0.0 (or add a central version).
Useful? React with 👍 / 👎.
|
|
||
| <ItemGroup> | ||
| <Content Include="..\Default\**" Link="Default\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" /> | ||
| <Content Include="..\MapManager\Shared\**" Link="Shared\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" /> |
There was a problem hiding this comment.
Copy Shared resources to the directory Config uses
When a test or helper actually uses a shared map/font/symbol file, this copies ..\MapManager\Shared\** under the test output's Shared child because CopyToOutputDirectory respects Link metadata (MSBuild item docs). However MapManager.Apis.Config.Shared resolves shared files two parents above the assembly directory plus Shared (for example bin\Shared from bin\Debug\net48), so these copied files land in a directory the code never reads and SharedDefaultMap.File.Exists/file opens can still fail after build. Use a TargetPath or copy target that places them in the Shared directory that Config.Shared resolves.
Useful? React with 👍 / 👎.
| { | ||
| public class ConfigTest | ||
| { | ||
| private static string OutputDirectory => AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); |
There was a problem hiding this comment.
Qualify AppContext so the test project builds
In this net48 project, implicit global usings are not enabled in the project file, so AppContext is not in scope here. A clean build of the test assembly will fail on this added expression before discovery can run; add using System; or qualify it as System.AppContext so the new discovery setup can compile.
Useful? React with 👍 / 👎.
Part of mapdojo/Xyzt#171.
Adds the xUnit VSTest adapter and test-project marker so MapManager.UnitTests is discovered by the Apis.Bake gate. Copies the Default and Shared fixtures into test output and makes Config path assertions portable across checkout and target-framework paths.
Verification:
Related: mapdojo/Xyzt#171