-
-
Notifications
You must be signed in to change notification settings - Fork 848
Complete Pester 5 migration - Migrate final 4 meta-tests and fix duplicate test execution #9937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replaces Select-Object -Unique with Sort-Object -Property FullName -Unique when combining test lists to ensure consistent ordering and uniqueness. This improves reliability when filtering and running tests based on dependencies.
Updated dbatools.Tests.ps1 to use BeforeAll blocks and global variables for test data setup, improving test isolation and performance. Standardized assertions to use '-Not -BeNullOrEmpty' and '-Be' syntax, added missing checks for edge cases, and improved code readability and maintainability.
Modernizes the test file to use Pester 5 syntax, improves parameter validation, and updates assertions to use the latest Should syntax. Also fixes variable usage and clarifies test contexts for one, two, and three part object names.
Updated the test script to use Pester 5 syntax and parameterization. Replaced dynamic command name assignment and improved handling of test configuration. Also fixed the duplicate command test to use Join-Path and updated assertion for null or empty results.
Rewrote help validation logic to use Pester Describe and Context blocks for improved structure and reporting. Added parameterization, consolidated repeated logic, and enhanced checks for command and parameter help consistency.
All tests have been migrated to Pester 5, so we can now remove the Pester 4 infrastructure: - Removed Get-PesterTestVersion function (no longer needed) - Removed Pester 4 test execution loop - Simplified Get-ComprehensiveErrorMessage to only handle Pester 5 format - Simplified Export-TestFailureSummary to only handle Pester 5 format - Removed PesterVersion parameter from all function calls - Updated finalization to only process Pester5Results files - Cleaned up all Pester 4 specific code paths This simplifies the test pipeline and reduces maintenance overhead now that the migration is complete. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Enhanced Get-ObjectNameParts to handle null values when replacing schema parts, preventing errors. Updated tests to cover additional edge cases and corrected expected results for bracketed names. Changed test collection logic in appveyor.common.ps1 to use Group-Object for deduplication instead of Sort-Object -Unique, ensuring more reliable test selection.
Code Review - Complete Pester 5 MigrationGreat work completing the Pester 5 migration! This is a significant milestone. I've reviewed the changes and have the following feedback: ✅ Strengths
🐛 Critical Bug FoundFile: # WRONG - $input is an automatic variable, not the test array
for ($i = 0; $i -lt $input.Count; $i++) {
# CORRECT - Should use $objectName
for ($i = 0; $i -lt $objectName.Count; $i++) {Impact: The loop will likely iterate 0 times since Recommendation: Fix this in all three test contexts before merging.
|
|
@claude please implement all suggested changes except the double quotes -- leave that as single quotes |
|
Claude finished @potatoqualitee's task —— View job Implementation Complete ✅I've successfully implemented the requested changes from the code review. Tasks Completed:
Summary of ChangesWhat was already fixed in the PR:
What I changed:
Commit
The PR is now ready with all the code review improvements, keeping your preferred single quote style for test strings. --- | |
|
@niphlod please review, it reduces the run time by a lot |
Per maintainer preference, keep single quotes for test strings. Co-authored-by: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
|
k gonna merge pls submit a PR to fix anything 🙏🏼 or feel feel free to revert |
This PR completes the Pester 5 migration by converting the final 4 remaining test files, fixing a CI bug, and removing all Pester 4 infrastructure from the codebase.
Test Migration (Pester 4 → Pester 5)
Migrated the final 4 test files to Pester 5:
Key improvements:
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0" }to all migrated filesBeforeAllblocks and global variables for better test isolationCI Bug Fix
Fixed duplicate test execution issue in
appveyor.common.ps1:Select-Object -UniquetoSort-Object -Property FullName -Uniquedbatools.Tests.ps1was running 3 times during PR buildsPester 4 Infrastructure Removal
Cleaned up all Pester 4 code from the CI pipeline:
appveyor.pester.ps1:
Get-PesterTestVersionfunction (no longer needed)Get-ComprehensiveErrorMessageto only handle Pester 5 formatExport-TestFailureSummaryto only handle Pester 5 formatappveyor.prep.ps1:
Migration Status
✅ 100% Complete - All 704 test files now use Pester 5
Code Stats