Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/advanced/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

IdLE is designed to be testable in isolation. Tests should be deterministic, fast, and runnable on any machine (local or CI) without requiring live systems.

## Test folder structure

Tests are organized by domain under `tests/`:

- **`tests/Core/`** — Core engine functionality (plan creation, execution, conditions, workflows, capabilities, redaction)
- **`tests/Steps/`** — Step implementations (built-in steps like EnsureEntitlement, Mailbox operations, DirectorySync)
- **`tests/Providers/`** — Provider implementations (AD, EntraID, ExchangeOnline, Mock, DirectorySync)
- **`tests/Packaging/`** — Module manifests, public API surface, release artifacts
- **`tests/Examples/`** — Workflow samples and demo smoke tests
- **`tests/fixtures/`** — Test data and workflow definitions for tests
- **`tests/_testHelpers.ps1`** — Shared test infrastructure (single entry point for all tests)

All test files follow the naming convention `*.Tests.ps1` and are automatically discovered by Pester.

Test helper functions are split by domain:
- `tests/_testHelpers.ps1` (main entry point, imports domain helpers)
- `tests/Steps/_testHelpers.Steps.ps1` (step-specific helpers)
- `tests/Providers/_testHelpers.Providers.ps1` (provider-specific helpers)

## Running tests locally

Use the canonical test runner:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# Import mailbox steps module for capability metadata
$mailboxStepsPath = Join-Path $PSScriptRoot '..' 'src' 'IdLE.Steps.Mailbox' 'IdLE.Steps.Mailbox.psd1'
$mailboxStepsPath = Join-Path $PSScriptRoot '..' '..' 'src' 'IdLE.Steps.Mailbox' 'IdLE.Steps.Mailbox.psd1'
if (Test-Path $mailboxStepsPath) {
Import-Module $mailboxStepsPath -Force -ErrorAction SilentlyContinue
}
Expand All @@ -27,7 +27,7 @@ Describe 'Capability Deprecation and Migration' {
}

# Use a real workflow file that uses mailbox steps
$wfPath = Join-Path $PSScriptRoot '..' 'examples' 'workflows' 'live' 'exo-leaver-mailbox-offboarding.psd1'
$wfPath = Join-Path $PSScriptRoot '..' '..' 'examples' 'workflows' 'live' 'exo-leaver-mailbox-offboarding.psd1'

# Verify the workflow file exists
$wfPath | Should -Exist
Expand Down Expand Up @@ -65,7 +65,7 @@ Describe 'Capability Deprecation and Migration' {
}

# Use a real workflow file
$wfPath = Join-Path $PSScriptRoot '..' 'examples' 'workflows' 'live' 'exo-leaver-mailbox-offboarding.psd1'
$wfPath = Join-Path $PSScriptRoot '..' '..' 'examples' 'workflows' 'live' 'exo-leaver-mailbox-offboarding.psd1'

$req = New-IdleLifecycleRequest -LifecycleEvent 'Leaver'
$providers = @{ MockProvider = $mockProvider }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeDiscovery {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down Expand Up @@ -48,7 +48,7 @@ Describe 'Export-IdlePlan' {

$plan = New-IdlePlan -WorkflowPath $wfPath -Request $req -Providers $providers

$expectedPath = Join-Path $PSScriptRoot 'fixtures/plan-export/expected/plan-export.json'
$expectedPath = Join-Path $PSScriptRoot '..' 'fixtures/plan-export/expected/plan-export.json'
$expectedJson = Get-Content -Path $expectedPath -Raw -Encoding utf8

# Act
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeDiscovery {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
$repoRoot = Get-RepoRootPath
$importScript = Join-Path -Path $repoRoot -ChildPath 'tools/import-idle.ps1'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeDiscovery {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
BeforeDiscovery {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# Create a dedicated test module for retry profile testing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
BeforeDiscovery {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# Create a dedicated, ephemeral test module that exports the step handlers.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# The meta module (IdLE) does not automatically import optional step packs.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# The engine invokes step handlers by function name (string) inside module scope.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
$fixturesPath = Join-Path $PSScriptRoot 'fixtures/workflows'
$fixturesPath = Join-Path $PSScriptRoot '..' 'fixtures/workflows'
}

Describe 'New-IdlePlan - required provider capabilities' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeDiscovery {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
$fixturesPath = Join-Path $PSScriptRoot 'fixtures/workflows'
$fixturesPath = Join-Path $PSScriptRoot '..' 'fixtures/workflows'
}

Describe 'Resolve-IdleStepMetadataCatalog - step pack catalog ownership' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# Helper to get fixture workflow path
function Get-TemplateTestFixture {
param([string]$Name)
return Join-Path $PSScriptRoot "fixtures/workflows/template-tests/$Name.psd1"
return Join-Path $PSScriptRoot ".." "fixtures/workflows/template-tests/$Name.psd1"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeDiscovery {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

$workflowsPath = Join-Path -Path (Get-RepoRootPath) -ChildPath 'examples/workflows'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
BeforeAll {
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..')
$idlePsd1 = Join-Path $repoRoot 'src\IdLE\IdLE.psd1'
$corePsd1 = Join-Path $repoRoot 'src\IdLE.Core\IdLE.Core.psd1'
$stepsPsd1 = Join-Path $repoRoot 'src\IdLE.Steps.Common\IdLE.Steps.Common.psd1'
$providerMockPsd1 = Join-Path $repoRoot 'src\IdLE.Provider.Mock\IdLE.Provider.Mock.psd1'

. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# The engine invokes step handlers by function name (string).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')

$script:RepoRoot = Get-RepoRootPath
$script:ReleaseScriptPath = Join-Path $script:RepoRoot 'tools/New-IdleReleaseArtifact.ps1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
17 changes: 17 additions & 0 deletions tests/Providers/_testHelpers.Providers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Set-StrictMode -Version Latest

<#
.SYNOPSIS
Provider-specific test helpers for IdLE tests.

.DESCRIPTION
This file contains helper functions, fixtures, and test doubles specifically
related to provider testing.

This file is sourced by tests/_testHelpers.ps1 and should not be dot-sourced
directly by test files.
#>

# Provider-specific helpers will be added here as needed.
# This file is currently empty but provides a clear extension point for
# provider-related test infrastructure.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Describe 'IdLE.Steps - Auth Session Routing' {

BeforeAll {
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '../src/IdLE/IdLE.psd1') -Force
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '../src/IdLE.Core/IdLE.Core.psd1') -Force
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '../src/IdLE.Steps.Common/IdLE.Steps.Common.psd1') -Force
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '../../src/IdLE/IdLE.psd1') -Force
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '../../src/IdLE.Core/IdLE.Core.psd1') -Force
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '../../src/IdLE.Steps.Common/IdLE.Steps.Common.psd1') -Force
}

Context 'EnsureAttribute - Auth Session Acquisition' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# Import Mailbox step pack
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# Import Mailbox step pack
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule

# Import Mailbox step pack
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest

BeforeAll {
. (Join-Path $PSScriptRoot '_testHelpers.ps1')
. (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
Import-IdleTestModule
}

Expand Down
Loading