Migrate Get-Package E2E tests to fast cmdlet-level unit tests#7457
Draft
nkolev92 wants to merge 17 commits into
Draft
Migrate Get-Package E2E tests to fast cmdlet-level unit tests#7457nkolev92 wants to merge 17 commits into
nkolev92 wants to merge 17 commits into
Conversation
- Remove duplicate private static GetConsole method in GetPackageTestCase.cs that hid the inherited protected base member (CS0108) and incorrectly used inaccessible GetComponentModelService<T>() (CS0122). - Remove unused 'using NuGet.Test.Utility;' from GetPackageTestCase.cs (IDE0005). - Remove unused 'using System.Linq;' from NuGetConsoleTestCase.cs (IDE0005). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e-duplicates' into dev-nkolev92-powershellCmdletTests
- 16 tests covering ListAvailable, Updates, and Installed scenarios - Tests invoke GetPackageCommand directly in a PowerShell runspace - Covers prerelease filtering, version collapsing, project filtering - Replaces need for expensive Apex E2E tests (PR #7452) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ration test Consolidate 15 individual Apex tests into one combined test that exercises the full Get-Package lifecycle: Install → List Installed → ListAvailable → Updates. Detailed filtering logic (prerelease, AllVersions) is now covered by fast cmdlet-level unit tests in GetPackageCommandTests.cs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Progress: https://github.com/NuGet/Client.Engineering/issues/2085
Description
Migrates
Get-Packageend-to-end PowerShell tests to fast, focused unit tests that invokeGetPackageCommanddirectly in a test runspace. This replaces the approach in #7452 (Apex migration) with a significantly cheaper and more faithful alternative.Approach
Instead of many individual Apex E2E tests (which each require a full VS instance), this PR:
GetPackageCommandin anInitialSessionStatewith aSessionStateCmdletEntryRunspacewith a customTestPSHostproviding requiredPrivateData(activePackageSource,CancellationTokenKey)MockedVS+IComponentModel(same pattern asNuGet.PackageManagement.VisualStudio.Test)SimpleTestPathContext+SimpleTestPackageUtilityPowerShellRemotePackage,PowerShellUpdatePackage,PowerShellInstalledPackage)Benefits over Apex tests
Changes
NuGetConsole.Host.PowerShell.Test/Cmdlets/GetPackageCommandTests.cscovering:GetPackage_InstallListAndUpdateLifecycleAsync) that validates the full PMC lifecycle in a single VS session: Install → Get-Package → Get-Package -ListAvailable → Get-Package -Updates -PrereleaseGetPackageViewModelTests.cs(unfaithful unit tests that only tested static view model methods)Migration mapping from original PS1 tests
Test-GetPackageCollapsesPackageVersionsForListAvailableGetPackageListAvailable_WithLocalSource_ReturnsPackagesAsyncTest-GetPackageAcceptsSourceNameGetPackageListAvailable_WithFilter_ReturnsMatchingPackageAsyncTest-GetPackageAcceptsAbsolutePathSourceGetPackageListAvailable_WithAbsolutePathSource_ReturnsPackagesAsyncTest-ZipPackageLoadsReleaseNotesAttributeGetPackageListAvailable_WithFilter_FindsReleaseNotesPackageAsyncTest-GetPackagesDoesNotShowPrereleasePackagesWhenSwitchIsNotSpecifiedGetPackageListAvailable_WithoutPrerelease_HidesPrereleaseVersionsAsyncTest-GetPackagesAllVersionsDoesNotShowPrereleasePackagesWhenSwitchIsNotSpecifiedGetPackageListAvailable_AllVersionsWithoutPrerelease_HidesPrereleaseVersionsAsyncTest-GetPackagesWithPrereleaseSwitchShowsPrereleasePackagesGetPackageListAvailable_WithPrerelease_ShowsPrereleaseVersionAsyncTest-GetPackagesWithAllAndPrereleaseSwitchShowsAllPackagesGetPackageListAvailable_AllVersionsWithPrerelease_ShowsAllVersionsAsyncTest-GetPackageUpdatesDoNotReturnPrereleasePackagesIfFlagIsNotSpecifiedGetPackageUpdates_WithoutPrerelease_DoesNotReturnPrereleaseUpdateAsyncTest-GetPackageUpdatesReturnPrereleasePackagesIfFlagIsSpecifiedGetPackageUpdates_WithPrerelease_ReturnsPrereleaseUpdateAsyncTest-GetPackageUpdatesReturnAllVersionsIfFlagIsSpecifiedGetPackageUpdates_AllVersionsWithoutPrerelease_ReturnsStableVersionAsyncTest-GetPackageUpdatesReturnAllVersionsAndPrereleaseVersionsIfTwoFlagsAreSpecifiedGetPackageUpdates_AllVersionsWithPrerelease_ReturnsAllEligibleUpdatesAsyncTest-GetPackageWithUpdatesListsUpdatesGetPackageInstalled_ListsInstalledPackagesAsyncPR Checklist