Skip to content

test: enable MapManager unit test discovery#3

Merged
bradbrowne merged 1 commit into
xyztfrom
codex/xyzt/mapmanager-test-discovery
Jul 23, 2026
Merged

test: enable MapManager unit test discovery#3
bradbrowne merged 1 commit into
xyztfrom
codex/xyzt/mapmanager-test-discovery

Conversation

@bradbrowne

Copy link
Copy Markdown

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:

  • dotnet restore MapManager.UnitTests/MapManager.UnitTests.csproj
  • dotnet build MapManager.UnitTests/MapManager.UnitTests.csproj --no-restore -m:1 /p:UseSharedCompilation=false
  • local dotnet test discovers 25 tests; native GDAL/MapServer tests require the configured native runtime/data environment

Related: mapdojo/Xyzt#171

Copilot AI review requested due to automatic review settings July 23, 2026 03:52
@bradbrowne
bradbrowne merged commit f5f3450 into xyzt Jul 23, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.UnitTests as a test project and add the xunit.runner.visualstudio adapter.
  • Copy Default / Shared fixture content into build output for tests.
  • Replace hard-coded absolute path assertions in ConfigTest with 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.

Comment on lines 1 to 5
using MapManager.Apis;
using Serilog;
using Serilog.Events;
using System.IO;
using Xunit;
Comment on lines +26 to +27
<Content Include="..\Default\**" Link="Default\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
<Content Include="..\MapManager\Shared\**" Link="Shared\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
Comment on lines 17 to +18
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio" />

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants