Skip to content

Add unit tests for the parser layer#98

Merged
PhoenixNil merged 1 commit into
mainfrom
test/parser-layer-unit-tests
Jul 17, 2026
Merged

Add unit tests for the parser layer#98
PhoenixNil merged 1 commit into
mainfrom
test/parser-layer-unit-tests

Conversation

@PhoenixNil

@PhoenixNil PhoenixNil commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds XrayUI.Tests, a plain net10.0 xunit project covering NodeLinkParser, NodeLinkSerializer, ClashConfigParser, and CustomRuleValueParser — the only parts of the codebase with zero test coverage despite carrying the most user-visible risk (a dropped field produces a config that looks valid but silently fails to connect; see the VLESS-XHTTP mode/extra bug).
  • Source-links the pure-logic production files instead of referencing the WinUI app project, so the test build never touches XAML compile or CsWinRT. WinAppSDK-backed dependencies (L/Loc, AppJsonSerializerContext.WriteReadable) are stubbed test-side.
  • 49 tests: per-protocol link parsing, Parse → ToLink → Parse round-trip equality (via reflection over ServerEntry's public properties, so a newly persisted field is covered automatically without editing the test), Clash YAML import, and custom-rule value parsing.
  • Wires a new test job into build.yml, running in parallel with the existing AOT publish job.

Scope is deliberately parser-layer only. Config-builder shape tests and xray.exe run -test smoke tests were prototyped and dropped as more complexity than wanted for this repo.

Test plan

  • dotnet test XrayUI.Tests/XrayUI.Tests.csproj -c Release — 49/49 passing locally
  • .\BuildAndRun.ps1 -SkipRun — confirms the new XrayUI.Tests\** glob exclusion doesn't affect the main app build
  • dotnet sln XrayUI-dev.slnx list — confirms the test project is registered correctly
  • CI test job (will run on this PR)

🤖 Generated with Claude Code

Repo had zero test coverage. NodeLinkParser, NodeLinkSerializer, and
ClashConfigParser carry the most user-visible risk in the codebase (a
dropped field silently produces a working-looking config that just
times out — see the VLESS-XHTTP mode/extra bug) with no automated
regression guard.

XrayUI.Tests is a plain net10.0 xunit project that source-links the
pure-logic production files instead of referencing the WinUI app
project, so the test build never touches XAML compile or CsWinRT.
WinAppSDK-backed dependencies (L/Loc, AppJsonSerializerContext) are
stubbed test-side. 49 tests: link parsing per protocol, Parse -> ToLink
-> Parse round-trip equality (via reflection over ServerEntry's public
properties, so a newly persisted field is covered automatically),
Clash YAML import, and custom-rule value parsing.

CI runs it as a new `test` job in build.yml, parallel to the existing
AOT publish job.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@PhoenixNil
PhoenixNil merged commit f2309e2 into main Jul 17, 2026
3 of 6 checks passed
@PhoenixNil
PhoenixNil deleted the test/parser-layer-unit-tests branch July 18, 2026 23:16
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.

1 participant