Comprehensive testing guide for PowerShell DevKit contributors.
PowerShell DevKit uses multiple testing approaches:
- Automated Code Validation - PSScriptAnalyzer
- Environment Validation - Test.ps1
- Manual Testing - Component functionality
- Integration Testing - Full workflow testing
# Run before every commit
.\Scripts\Validate-Code.ps1Checks:
- PSScriptAnalyzer rules
- Syntax errors
- Code formatting
- Best practices compliance
Must pass before committing!
# Validate installation
.\Scripts\Test.ps1Checks:
- Component installation status
- Component versions
- Configuration deployment
- Module availability
Test each component can be installed:
# Fresh install
.\Scripts\Setup.ps1
# Skip optional
.\Scripts\Setup.ps1 -SkipOptional
# Verify
.\Scripts\Test.ps1Test updates work correctly:
# Update all
.\Scripts\Update.ps1
# Update specific types
.\Scripts\Update.ps1 -WingetOnly
.\Scripts\Update.ps1 -ModulesOnly
# Verify
.\Scripts\Test.ps1Test configuration files deploy correctly:
# Deploy profile
.\Scripts\Setup.ps1
# Verify profile exists
Test-Path $PROFILE
# Verify profile loads
. $PROFILE
# Deploy terminal
.\Scripts\Deploy-Terminal.ps1
# Verify terminal settings
Test-Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_*\LocalState\settings.json"Test failure scenarios:
# Network timeout (disconnect network)
.\Scripts\Setup.ps1
# Check failure logging
.\Scripts\Setup.ps1 -ShowDetails
# Permission errors (run as standard user)
.\Scripts\Setup.ps1
# Missing prerequisites (uninstall winget)
.\Scripts\Setup.ps1Test complete installation workflow:
# 1. Clean environment (VM recommended)
# 2. Clone repository
git clone https://github.com/Tsabo/PowerShell-DevKit.git
cd PowerShell-DevKit
# 3. Run setup
.\Scripts\Setup.ps1
# 4. Validate
.\Scripts\Test.ps1
# 5. Test profile
. $PROFILE
# 6. Test components
yazi
y
oh-my-posh version
z --version
# 7. Test updates
.\Scripts\Update.ps1
# 8. Re-validate
.\Scripts\Test.ps1Verify setup is idempotent:
# Run setup multiple times
.\Scripts\Setup.ps1
.\Scripts\Setup.ps1
.\Scripts\Setup.ps1
# Should skip already-installed components
# Should not show errorsTest update preserves customizations:
# 1. Fresh install
.\Scripts\Setup.ps1
# 2. Create customizations
Copy-Item "PowerShell\CustomProfile.ps1.template" "PowerShell\CustomProfile.ps1"
New-Item "PowerShell\CustomModules\test.psm1"
# 3. Pull updates
git pull
# 4. Run setup again
.\Scripts\Setup.ps1
# 5. Verify customizations preserved
Test-Path "PowerShell\CustomProfile.ps1"
Test-Path "PowerShell\CustomModules\test.psm1"# Check installation
oh-my-posh version
# Test theme
oh-my-posh init pwsh --config ".\Config\oh-my-posh\iterm2.omp.json" | Invoke-Expression
# Verify font
# Check terminal displays icons correctly# Check installation
yazi --version
# Test launch
yazi
# Test directory change function
y
# Test plugins
# Navigate to git repository
# Verify git status shows# Check modules installed
Get-Module -ListAvailable PSFzf
Get-Module -ListAvailable Terminal-Icons
Get-Module -ListAvailable posh-git
# Test module import
Import-Module PSFzf
Import-Module Terminal-Icons
# Test functionality
Ctrl+R # PSFzf history
ls # Terminal-Icons- Primary Development - Windows 11, PowerShell 7, all components
- Minimal Setup - Windows 10, PowerShell 7, no optional components
- Clean Install - Fresh Windows VM, first-time installation
- Upgrade Path - Existing installation → pull updates → re-run setup
Use VMs for destructive testing:
- Fresh Windows installation
- Test installation from scratch
- Test with limited permissions
- Test with network restrictions
Test on multiple Windows versions:
- Windows 10 (latest)
- Windows 11
- Windows Server 2022 (if applicable)
-
Validate-Code.ps1passes -
Test.ps1passes - Manually tested changes
- Documentation updated
- No syntax errors
- All automated tests pass
- Manual testing completed
- Integration testing completed
- Clean install tested (VM)
- Update workflow tested
- Documentation accurate
- Component defined in Components.psm1
- Installation tested
- Validation tested
- Update tested
- Documentation added
- Optional flag set correctly
# 1. Add component to Components.psm1
# 2. Test installation
.\Scripts\Setup.ps1
# 3. Verify in Test.ps1
.\Scripts\Test.ps1
# 4. Test update
.\Scripts\Update.ps1
# 5. Document in docs/components/# 1. Modify profile
# 2. Test loading
. $PROFILE
# 3. Check for errors
# 4. Test functions work
# 5. Restart PowerShell and verify# 1. Cause intentional failure (disconnect network)
.\Scripts\Setup.ps1
# 2. Check failure logged
.\Scripts\Setup.ps1 -ShowDetails
# 3. Fix issue (reconnect network)
# 4. Re-run setup
.\Scripts\Setup.ps1
# 5. Verify recovery worked# Verbose messages
.\Scripts\Setup.ps1 -Verbose
# Debug messages
$DebugPreference = "Continue"
.\Scripts\Setup.ps1# View setup logs
.\Scripts\Setup.ps1 -ShowDetails
# View update logs
.\Scripts\Update.ps1 -ShowDetails
# Read JSON directly
Get-Content .\Scripts\Logs\setup-details.json | ConvertFrom-Json# Test profile without loading
powershell -NoProfile -Command ". '$PROFILE'"
# Check specific module
Import-Module .\PowerShell\IncludedModules\utilities.psm1 -VerboseWhen CI is set up:
- name: Validate Code
run: .\Scripts\Validate-Code.ps1
- name: Test Environment
run: .\Scripts\Test.ps1