Like Chocolatey CLI, Chocolatey GUI also has tests. A good place to start to understand Chocolatey testing is the Chocolatey CLI TESTING.md document. In addition to the Unit and Integration tests, Chocolatey GUI has a UITests project.
When run from Visual Studio, Chocolatey GUI can operate in one of three setups:
- (Default for
DEBUGbuilds) Isolated local install. ADEBUGbuild of Chocolatey GUI pointsChocolateyInstallat the directory the GUI is running from (itsbin\Debug\net48output), so Chocolatey reads/writes its ownlib,config,.chocolateystore, etc. there instead of touching the machine-wide install. This keeps debugging fully isolated from the Chocolatey installed on your system, mirroring how Chocolatey CLI behaves when debugged out of Visual Studio. A fresh isolated config starts with only the defaultchocolateycommunity source. To use a folder of your choosing instead of thebinoutput, set theChocolateyGuiDebugInstallenvironment variable to that path. - The Chocolatey installed to the system (generally
C:\ProgramData\chocolatey). To use this from aDEBUGbuild (the old default behaviour), set the environment variableChocolateyGuiUseSystemInstall=true.Release/ReleaseOfficialbuilds always use the system install, so this is also the behaviour in CI. - A debug build of Chocolatey "installed" into the same directory that Chocolatey GUI is running from. This occurs when you run
.\Get-ChocoUpdatedDebugVersion.ps1, which swaps aDEBUG-compiledchocolatey.dllin for the referenced (official) one - use this when you need to step into / change Chocolatey.lib itself.
Requires Dev Proxy. The isolated remote-source UITests (
ChocolateyGuiSearchTests,ChocolateyGuiInstalledPackageTests) mock thecommunity.chocolatey.orgfeed through Dev Proxy, so they need it installed (e.g.winget install DevProxy.DevProxy, or pointDEVPROXY_PATHat the executable). They run against setup 1 above and are skipped - not failed - when Dev Proxy cannot be found.
Self-contained WireMock feed. The remote-source UITests that need the
hermessource and itsmixedpackagepackage (BetaPackagesTests,ChocolateyGuiTestsandRemoteSourceOutdatedTests) now serve that source from an in-process WireMock.Net OData feed (seeSource/ChocolateyGui.UITests/Support/Feed/), registered automatically against the isolated install (setup 1) for the lifetime of the fixture. There is no manual setup - you no longer need to add ahermessource or obtain the internalmixed-packagepackage from a Chocolatey-internal NuGet repository.
Outdated / prerelease-upgrade tests.
RemoteSourceOutdatedTests(issue #1109 regression) additionally seeds an installed package into the isolated install before launch (IsolatedChocolateyEnvironment.SeedInstalledPackage, which generates a minimal stub.nupkgon the fly) and clears Chocolatey GUI's persisted outdated-packages cache (%LocalAppData%\Chocolatey GUI\outdatedPackages*.xml, cached for 60 minutes by default) so the outdated check runs fresh against the mock feed. No extra setup is required from you.
Run the tests elevated. Chocolatey GUI self-elevates (its executable carries a
requireAdministratormanifest), and Windows UIPI prevents a non-elevated process from driving an elevated window. The UITests must therefore run from an elevated host - an Administrator Test Explorer (launch Visual Studio as Administrator) or an elevateddotnet test. From a non-elevated host the GUI opens but cannot be automated, and the tests time out with "Could not start the application".
You can run the UITests by opening the Test Explorer (View -> Test Explorer), right clicking the ChocolateyGui.UITests collection, and select Run. IMPORTANT: Once you select to run the tests, DO NOT use your mouse or keyboard. The tests rely on interacting with the Chocolatey GUI window, and using the mouse or keyboard could impact that and cause tests to fail.