Skip to content

fix: Add automated end-to-end testing using playground in CI/CD workflows#49

Open
mfogliatto wants to merge 10 commits into
mainfrom
fix/issue-43
Open

fix: Add automated end-to-end testing using playground in CI/CD workflows#49
mfogliatto wants to merge 10 commits into
mainfrom
fix/issue-43

Conversation

@mfogliatto
Copy link
Copy Markdown
Owner

Summary

Adds automated end-to-end testing that validates ReferenceCop rule detection using the existing playground infrastructure, integrated into both PR and official build CI/CD workflows.

Changes

  • playground/Run-E2ETests.ps1 — PowerShell test runner that exercises all three rule types plus a valid-build scenario
  • playground/TestProject/InternalLib/ — Test fixture for ProjectPath rule validation
  • playground/TestProject/ToolsProject/ — Test fixture for ProjectTag rule validation
  • playground/TestProject/ValidApp/ — Test fixture for valid (no-violation) scenario
  • .github/workflows/pr-build.yaml — Added e2e test step after unit tests
  • .github/workflows/official-build.yaml — Added e2e test step after unit tests
  • playground/TEST-SCENARIOS.md — Documents all test scenarios
  • playground/playground.slnx — Updated to include new projects

Testing

The test runner validates:

  1. AssemblyName rule: SampleLibrary referencing Newtonsoft.Json triggers violation
  2. ProjectPath rule: SampleApp referencing InternalLib triggers violation
  3. ProjectTag rule: App-tagged project referencing Tools-tagged project triggers warning
  4. Valid build: ValidApp with no violations builds successfully

Run locally: ./playground/Run-E2ETests.ps1 -PackFirst

Fixes #43

mfogliatto added 10 commits May 24, 2026 08:03
Adds a PowerShell test runner (Run-E2ETests.ps1) that validates all three
ReferenceCop rule types (AssemblyName, ProjectTag, ProjectPath) plus a
valid-build scenario. Integrates into both PR and official build workflows.

New test projects: InternalLib, ToolsProject, ValidApp provide test fixtures
for the ProjectPath, ProjectTag, and valid-build scenarios respectively.

Fixes #43
In .NET 8, System.Web.HttpUtility is a legitimate shared framework
assembly. The wildcard pattern System.Web* incorrectly flags it in
ValidApp which has no actual System.Web dependency.
The System.Web assembly is part of the .NET 8 shared framework and
appears as a reference in all net8.0 projects. Removed the rule from
playground config since no test scenario exercises it. Changed
NoNewtonsoftJson to Error severity to ensure scenario 1 build fails.
Scenarios 2 (ProjectPath) and 3 (ProjectTag) replace SampleApp.csproj
to test different reference rules. The original Program.cs has
'using SampleLibrary' which causes CS0246 when SampleLibrary isn't
referenced. Use a minimal Program.cs for these scenarios so the
ReferenceCop analyzer can run without compilation errors.
The ToPath pattern was '**/Internal/**' but the actual test project
directory is 'InternalLib', not 'Internal'.
The ProjectPathViolationDetector uses string.StartsWith() not glob
matching. Paths are relative to ReferenceCopRepositoryRoot (the
TestProject directory). Use simple prefix 'SampleApp' and 'InternalLib'
to match the relative paths correctly.
Addresses review comment — pack should use Release, not Debug.
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.

Add automated end-to-end testing using playground in CI/CD workflows

1 participant