-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify Run-PesterTests.ps1 to run all tests regardless of the test su…
…bdirectory they are in.
- Loading branch information
1 parent
791b1da
commit 13feedd
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Load Pester module if not already loaded | ||
Import-Module -Name Pester -ErrorAction Stop | ||
|
||
# Log function for consistent output | ||
function Log { | ||
param( | ||
[string]$Message, | ||
[string]$Level = "Info" | ||
) | ||
$timestamp = Get-Date -Format "HH:mm:ss" | ||
Write-Output "[$timestamp][$Level] $Message" | ||
} | ||
|
||
# Start of test execution | ||
Log "Starting Tests" | ||
|
||
# Define the tests directory | ||
$testDirectory = "$PSScriptRoot" | ||
|
||
# Get all test files in the directory, excluding specific ones | ||
$testFiles = Get-ChildItem -Path $testDirectory -Recurse -Include *.Tests.ps1 | | ||
Where-Object { $_.Name -notin @('pester.ps1', 'Run-PesterTests.ps1') } | ||
|
||
# Ensure we found test files | ||
if (-not $testFiles) { | ||
Log "No test files found to execute." "Error" | ||
exit 1 | ||
} | ||
|
||
# Loop through each test file | ||
foreach ($testFile in $testFiles) { | ||
Log "Executing $($testFile.FullName)" "Info" | ||
try { | ||
# Run tests with minimal output | ||
Invoke-Pester -Path $testFile.FullName -Output Minimal -PassThru | Out-Null | ||
} catch { | ||
Log "Error running $($testFile.FullName): $_" "Error" | ||
} | ||
} | ||
|
||
Log "All tests executed successfully!" "Success" |