Skip to content

Tests - restructure folders and split helpers by domain (single entry point) #101

@blindzero

Description

@blindzero

Summary

The tests/ folder has grown and is now harder to navigate. We want:

  • a clear folder structure so tests are easy to find by domain
  • a maintainable helper setup by splitting _testHelpers into domain helper files while keeping one stable entry point

This issue covers both:

  • (3) Tests folder structure improvements
  • (4) _testHelpers split into domain helper files

Goals

  • Improve discoverability and reduce contributor friction
  • Keep one stable dot-source entry point for all tests
  • Keep CI green (Pester + PSScriptAnalyzer)

Non-goals

  • Renaming tests/_testHelpers.ps1
  • Introducing an Internal/ concept
  • Changing production code behavior (this is test-only refactoring)

Acceptance criteria

Folder structure

  • tests/ is organized into clearly named folders (see proposed structure below).
  • Test files remain named *.Tests.ps1.
  • Pester discovery still finds all tests and the suite remains green.

Helpers split (single entry point)

  • All tests continue to dot-source only tests/_testHelpers.ps1.
  • tests/_testHelpers.ps1 dot-sources domain helper files:
    • tests/Steps/_testHelpers.Steps.ps1
    • tests/Providers/_testHelpers.Providers.ps1
  • Domain helper files contain only helpers/fixtures/test-doubles (no tests).
  • No circular dot-sourcing dependencies between helper files.
  • $PSScriptRoot is used so relative paths remain robust after moves.

Proposed folder structure (tests)

Domain-oriented baseline:

  • tests/Core/
  • tests/Steps/
  • tests/Providers/ (already exists)
  • tests/Packaging/ (surface/manifest/release artifacts)
  • tests/Examples/ (workflow samples, demo smoke)

(Choose this scheme and apply consistently.)

Implementation tasks (agent-ready)

1) Reorganize tests into folders

  • Create the folders under tests/ as listed above.
  • Move existing test files into the appropriate folders, e.g.:
    • Core: Invoke-IdlePlan*.Tests.ps1, New-IdlePlan*.Tests.ps1, redaction/copy tests
    • Steps: Invoke-IdleStep*.Tests.ps1
    • Providers: keep tests/Providers/*
    • Packaging: module surface/manifests, release artifact tests
    • Examples: WorkflowSamples.Tests.ps1 and future demo smoke tests
  • Update any dot-sourcing paths only if needed (prefer $PSScriptRoot).
  • Ensure Pester discovery still runs the full suite.

2) Create domain helper files

  • Create tests/Steps/_testHelpers.Steps.ps1
    • Move step-related helper functions/fixtures from tests/_testHelpers.ps1 into this file (as appropriate).
  • Create tests/Providers/_testHelpers.Providers.ps1
    • Move provider-related helper functions/test doubles from tests/_testHelpers.ps1 into this file (as appropriate).

3) Update global helper to dot-source domain helpers

  • Update tests/_testHelpers.ps1 to dot-source the two new files early during setup.
  • Keep global-only responsibilities in tests/_testHelpers.ps1:
    • Importing the IdLE test module
    • Common/shared assertions/utilities
    • Global fixtures (temp paths etc.)

4) Verify quality gates

  • Pester green
  • PSScriptAnalyzer green
  • Git status clean

Suggested labels

  • refactor
  • testing
  • maintainability

Notes

  • If later needed, we can add additional domain helper files (e.g., Core/Packaging/Examples) following the same pattern, but start with Steps + Providers.

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions