Skip to content

Consolidate duplicated xUnit facts into theories - #2000

Merged
Aaronontheweb merged 1 commit into
devfrom
refactor/test-compression
Aug 19, 2026
Merged

Consolidate duplicated xUnit facts into theories#2000
Aaronontheweb merged 1 commit into
devfrom
refactor/test-compression

Conversation

@Aaronontheweb

@Aaronontheweb Aaronontheweb commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

What

Phase 1 of a code-reduction effort: compress duplicated test code without loss of coverage. 13 files changed, 1,032 insertions, 1,745 deletions (−713 net lines).

  • Collapse groups of near-identical [Fact] methods into [Theory] methods with MemberData/InlineData rows. Each old fact maps to exactly one theory row. All assertions and input literals are unchanged.
  • Extract repeated arrange blocks into shared helpers (RunCheckAsync in ConfigSchemaDoctorCheckTests, gateway-delivery helper in ReminderManagerActorTests, registry/policy construction in DispatchingToolExecutorTests).
  • Update ConfigEditorCoverageAuditTests nameof references to the merged theory.

Files

Project Files
Cli.Tests ExposureModeDoctorCheckTests, ConfigSchemaDoctorCheckTests, WebhooksCommandTests, ApprovalsCommandTests, ChannelsConfigViewModelTests, ConfigEditorCoverageAuditTests
Daemon.Tests RetryingChatClientTests
Security.Tests ToolPathPolicyTests, MagicByteValidatorTests, RegexPromptInjectionDetectorTests
Actors.Tests DispatchingToolExecutorTests, WebFetchToolTests, ReminderManagerActorTests (helper extraction only)

What was deliberately NOT consolidated

  • Tests that look similar but exercise different control-flow branches (ReminderManager delivery variants, SubAgent repair-turn tests) stay separate facts.
  • ChannelsConfigViewModelTests group "resolve channel name to id": the Slack variant drives a different flow with five extra assertions. A shared theory would obscure it.
  • CreateApprovalGatedShellExecutor was not substituted into the one-time-approval tests: its approvalService ?? new UnexpectedApprovalService() default differs from the raw constructor null. One test depends on the null behavior. The shared helper covers only registry/policy construction.

Verification

  • Executed test-case counts, before vs after, on identical filters: Cli 242→242, Daemon 12→12, Actors 217→217, Security 224→230. The +6 comes from a split of 7 multi-assert facts into 13 single-assert theory rows — each original assertion is now its own case.
  • All 701 affected tests pass. Zero skipped.
  • dotnet slopwatch analyze: 0 issues. Header verification passes. Build has 0 warnings.

Stack

PR 1 of a planned 4-phase stack. Next phases: cross-channel helper dedup, a NotifyDeliveryFailedAsync drift fix, and a binding-actor consolidation.

@Aaronontheweb Aaronontheweb changed the title refactor/test compression Consolidate duplicated xUnit facts into theories Aug 18, 2026
bool preWriteFile,
bool assertFileMissingAfter)
{
var filePath = Path.Combine(Path.GetTempPath(), $"netclaw-{toolName}-outside-{Guid.NewGuid():N}.txt");
buildArgs(filePath));

var sessionDir = Path.Combine(Path.GetTempPath(), $"netclaw-team-session-{Guid.NewGuid():N}");
var sessionDir = Path.Combine(Path.GetTempPath(), $"netclaw-{toolName}-session-{Guid.NewGuid():N}");

var registry = new ToolRegistry();
var paths = new NetclawPaths(Path.Combine(Path.GetTempPath(), $"netclaw-public-tools-{Guid.NewGuid():N}"));
var paths = new NetclawPaths(Path.Combine(Path.GetTempPath(), $"netclaw-{audience}-tools-{Guid.NewGuid():N}"));
var segments = relativePath.Split('/');

Assert.True(policy.IsDenied(Path.Combine(configDir, "future", "subsystem", "settings.json")));
Assert.True(policy.IsDenied(Path.Combine([configDir, .. segments])));
Collapse groups of near-identical [Fact] methods into [Theory] methods
with MemberData or InlineData rows. Extract repeated arrange blocks into
shared helpers. Each old fact maps to exactly one theory row. All
assertions and input literals are unchanged. No production code changes.

Files:
- Cli.Tests: ExposureModeDoctorCheckTests, ConfigSchemaDoctorCheckTests,
  WebhooksCommandTests, ApprovalsCommandTests, ChannelsConfigViewModelTests
- Daemon.Tests: RetryingChatClientTests
- Security.Tests: ToolPathPolicyTests, MagicByteValidatorTests,
  RegexPromptInjectionDetectorTests
- Actors.Tests: DispatchingToolExecutorTests, WebFetchToolTests,
  ReminderManagerActorTests (helper extraction only)
- ConfigEditorCoverageAuditTests: update nameof references to the merged
  theory
@Aaronontheweb
Aaronontheweb force-pushed the refactor/test-compression branch from 7f9529d to a58f8de Compare August 19, 2026 02:08
@Aaronontheweb Aaronontheweb added the cleanup Code quality improvements and tech debt reduction label Aug 19, 2026
@Aaronontheweb
Aaronontheweb merged commit 8f89173 into dev Aug 19, 2026
31 of 33 checks passed
@Aaronontheweb
Aaronontheweb deleted the refactor/test-compression branch August 19, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Code quality improvements and tech debt reduction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant