|
| 1 | +# YamlCreate.InstallerDetection Tests |
| 2 | + |
| 3 | +This directory contains Pester tests for the YamlCreate.InstallerDetection PowerShell module. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The test suite validates the functionality of the installer detection module, which provides functions to: |
| 8 | +- Parse PE file structures |
| 9 | +- Detect various installer types (ZIP, MSIX, MSI, WIX, Nullsoft, Inno, Burn) |
| 10 | +- Identify font files |
| 11 | +- Resolve installer types from file paths |
| 12 | + |
| 13 | +## Running the Tests |
| 14 | + |
| 15 | +### Prerequisites |
| 16 | + |
| 17 | +- PowerShell 7.0 or later |
| 18 | +- Pester 5.x (included with PowerShell 7+) |
| 19 | + |
| 20 | +### Run All Tests |
| 21 | + |
| 22 | +From the module directory, run: |
| 23 | + |
| 24 | +```powershell |
| 25 | +Invoke-Pester -Path ./YamlCreate.InstallerDetection.Tests.ps1 |
| 26 | +``` |
| 27 | + |
| 28 | +### Run Tests with Detailed Output |
| 29 | + |
| 30 | +For more detailed test output: |
| 31 | + |
| 32 | +```powershell |
| 33 | +Invoke-Pester -Path ./YamlCreate.InstallerDetection.Tests.ps1 -Output Detailed |
| 34 | +``` |
| 35 | + |
| 36 | +### Run Tests with Code Coverage |
| 37 | + |
| 38 | +To see code coverage metrics: |
| 39 | + |
| 40 | +```powershell |
| 41 | +Invoke-Pester -Path ./YamlCreate.InstallerDetection.Tests.ps1 -CodeCoverage ./YamlCreate.InstallerDetection.psm1 |
| 42 | +``` |
| 43 | + |
| 44 | +## Test Structure |
| 45 | + |
| 46 | +The test suite is organized into the following sections: |
| 47 | + |
| 48 | +### Module Tests |
| 49 | +- Module import validation |
| 50 | +- Exported functions verification |
| 51 | + |
| 52 | +### Function Tests |
| 53 | +- **Get-OffsetBytes**: Tests for byte array extraction with various offsets and endianness |
| 54 | +- **Get-PESectionTable**: Tests for PE file parsing |
| 55 | +- **Test-IsZip**: Tests for ZIP file detection |
| 56 | +- **Test-IsMsix**: Tests for MSIX/APPX detection |
| 57 | +- **Test-IsMsi**: Tests for MSI installer detection |
| 58 | +- **Test-IsWix**: Tests for WIX installer detection |
| 59 | +- **Test-IsNullsoft**: Tests for Nullsoft installer detection |
| 60 | +- **Test-IsInno**: Tests for Inno Setup installer detection |
| 61 | +- **Test-IsBurn**: Tests for Burn installer detection |
| 62 | +- **Test-IsFont**: Tests for font file detection (TTF, OTF, TTC) |
| 63 | +- **Resolve-InstallerType**: Tests for the main installer type resolution function |
| 64 | + |
| 65 | +## Known Limitations |
| 66 | + |
| 67 | +Some tests are skipped due to complexity or external dependencies: |
| 68 | + |
| 69 | +1. **ZIP Archive Tests**: Tests that require complete valid ZIP archives are skipped as they would need complex ZIP structure generation |
| 70 | +2. **PE File Tests**: Some PE-related tests are skipped when they would require reading non-existent files |
| 71 | +3. **External Dependencies**: The module relies on external commands (`Get-MSITable`, `Get-MSIProperty`, `Get-Win32ModuleResource`) that are stubbed in the test environment |
| 72 | + |
| 73 | +## Test Coverage |
| 74 | + |
| 75 | +Current test coverage includes: |
| 76 | +- 32 passing tests |
| 77 | +- 3 skipped tests (require complex setup) |
| 78 | +- Covers all 11 exported functions |
| 79 | +- Tests both positive and negative scenarios |
| 80 | +- Validates edge cases and error handling |
| 81 | + |
| 82 | +## Contributing |
| 83 | + |
| 84 | +When adding new functions to the module: |
| 85 | +1. Add corresponding tests to `YamlCreate.InstallerDetection.Tests.ps1` |
| 86 | +2. Follow the existing test structure (Describe → Context → It blocks) |
| 87 | +3. Use descriptive test names that explain what is being tested |
| 88 | +4. Include both positive and negative test cases |
| 89 | +5. Clean up any temporary files created during tests |
| 90 | + |
| 91 | +## Additional Resources |
| 92 | + |
| 93 | +- [Pester Documentation](https://pester.dev/) |
| 94 | +- [PowerShell Testing Best Practices](https://pester.dev/docs/usage/test-file-structure) |
0 commit comments