{"id":15192245,"url":"https://github.com/powershell/psl-pester","last_synced_at":"2025-10-02T07:30:28.499Z","repository":{"id":65985532,"uuid":"49682142","full_name":"PowerShell/psl-pester","owner":"PowerShell","description":"Fork of Pester for compatibility with PowerShell on Linux.","archived":true,"fork":false,"pushed_at":"2018-06-11T21:59:23.000Z","size":2129,"stargazers_count":8,"open_issues_count":2,"forks_count":10,"subscribers_count":47,"default_branch":"develop","last_synced_at":"2024-09-28T21:20:24.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PowerShell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-14T23:28:44.000Z","updated_at":"2023-01-28T20:33:27.000Z","dependencies_parsed_at":"2023-02-19T18:45:16.143Z","dependency_job_id":null,"html_url":"https://github.com/PowerShell/psl-pester","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2Fpsl-pester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2Fpsl-pester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2Fpsl-pester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2Fpsl-pester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PowerShell","download_url":"https://codeload.github.com/PowerShell/psl-pester/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234951983,"owners_count":18912496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-27T21:20:22.101Z","updated_at":"2025-10-02T07:30:22.972Z","avatar_url":"https://github.com/PowerShell.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"NOTE\n====\n\n**This fork was a temporary solution for [cross-platform PowerShell](https://github.com/PowerShell/PowerShell).\nWe don't plan to maintain it or take any contributions.** \n\n**[Pester](https://github.com/pester/Pester) now supports cross-platform execution and this fork will be eventually removed.**\n\n------------------------------------------------------------------\n\nPester 3.0 has been released!  To see a list of changes in this version, refer to the [What's New in Pester 3.0?](https://github.com/pester/Pester/wiki/What's-New-in-Pester-3.0%3F) Wiki page.\n\n---\n\nPester\n=======\nPester provides a framework for **running Unit Tests to execute and validate PowerShell commands inside of PowerShell**. Pester follows a file naming convention for naming tests to be discovered by pester at test time and a simple set of functions that expose a Testing DSL for isolating, running, evaluating and reporting the results of Powershell commands.\n\nPester tests can execute any command or script that is accessible to a pester test file. This can include functions, Cmdlets, Modules and scripts. Pester can be run in ad hoc style in a console or **it can be integrated into the Build scripts of a Continuous Integration system**.\n\n**Pester also contains a powerful set of Mocking Functions** that allow tests to mimic and mock the functionality of any command inside of a piece of powershell code being tested.\n\nA Pester Test\n-------------\nBuildChanges.ps1\n\n```powershell\n\nfunction Build ($version) {\n  write-host \"a build was run for version: $version\"\n}\n\nfunction BuildIfChanged {\n  $thisVersion=Get-Version\n  $nextVersion=Get-NextVersion\n  if($thisVersion -ne $nextVersion) {Build $nextVersion}\n  return $nextVersion\n}\n```\n\nBuildChanges.Tests.ps1\n\n```powershell\n$here = Split-Path -Parent $MyInvocation.MyCommand.Path\n$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(\".Tests.\", \".\")\n. \"$here\\$sut\"\n\nDescribe \"BuildIfChanged\" {\n  Context \"When there are Changes\" {\n    Mock Get-Version {return 1.1}\n    Mock Get-NextVersion {return 1.2}\n    Mock Build {} -Verifiable -ParameterFilter {$version -eq 1.2}\n\n    $result = BuildIfChanged\n\n      It \"Builds the next version\" {\n          Assert-VerifiableMocks\n      }\n      It \"returns the next version number\" {\n          $result | Should Be 1.2\n      }\n    }\n  Context \"When there are no Changes\" {\n    Mock Get-Version -MockWith {return 1.1}\n    Mock Get-NextVersion -MockWith {return 1.1}\n    Mock Build {}\n\n    $result = BuildIfChanged\n\n      It \"Should not build the next version\" {\n          Assert-MockCalled Build -Times 0 -ParameterFilter{$version -eq 1.1}\n      }\n    }\n}\n```\n\nRunning Tests\n-------------\n    C:\\PS\u003e Invoke-Pester\n\nThis will run all tests inside of files named *.Tests.ps1 recursively from the current directory downwards and print a report of all failing and passing tests to the console.\n\nContinuous Integration with Pester\n-----------------------------------\n\nPester integrates well with almost any build automation solution.  There are several options for this integration:\n\n- The `-OutputFile` parameter allows you to export data about the test execution.  Currently, this parameter allows you to produce NUnit-style XML output, which any modern CI solution should be able to read.\n- The `-PassThru` parameter can be used if your CI solution supports running PowerShell code directly.  After Pester finishes running, check the FailedCount property on the object to determine whether any tests failed, and take action from there.\n- The `-EnableExit` switch causes Pester to exit the current PowerShell session with an error code.  This error code will be the number of failed tests; 0 indicates success.\n\nAs an example, there is also a file named `Pester.bat` in the `bin` folder which shows how you might integrate with a CI solution that does not support running PowerShell directly.  By wrapping a call to Invoke-Pester in a batch file, and making sure that batch file returns a non-zero exit code if any tests fail, you can still use Pester even when limited to commands run from cmd.exe in your CI jobs.\n\nWhenever possible, it's better to run Invoke-Pester directly (either in an interactive PowerShell session, or using CI software that supports running PowerShell steps in jobs.)  This is the method that we test and support in our releases.\n\nSome further reading and resources:\n-----------------------------------\n* [Getting started with Pester](http://www.powershellmagazine.com/2014/03/12/get-started-with-pester-powershell-unit-testing-framework/)\n* [Testing your scripts with Pester, Assertions and more](http://www.powershellmagazine.com/2014/03/27/testing-your-powershell-scripts-with-pester-assertions-and-more/)\n* [The Wiki](https://github.com/pester/Pester/wiki)\n* [Google Discussion Group](https://groups.google.com/forum/?fromgroups#!forum/pester)\n* `C:\\PS\u003e Import-Module ./pester.psm1; Get-Help about_pester`\n* Note: The following two links were for Pester v1.0.  The syntax shown, particularly for performing Assertions with Should, is no longer applicable to later versions of Pester.\n    * [powershell-bdd-testing-pester-screencast](http://scottmuc.com/blog/development/powershell-bdd-testing-pester-screencast/)\n    * [pester-bdd-for-the-system-administrator](http://scottmuc.com/blog/development/pester-bdd-for-the-system-administrator/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowershell%2Fpsl-pester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpowershell%2Fpsl-pester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowershell%2Fpsl-pester/lists"}