PowerShell/test/powershell
2016-10-12 14:58:22 -07:00
..
Common Fix Get-Credential to not prompt twice when no parameter is specified 2016-09-27 09:49:28 -07:00
engine Skipping New-PSRoleCapabilityFile and Get-PSSessionCapability on help system test since there is no help content for these two cmdlets (#2464) 2016-10-12 12:17:51 -07:00
Host Fix host remote test InvokeOnRunspace to work with AppVeyor (#2362) 2016-10-10 15:24:04 -07:00
Language Fix variable assignment to not overwrite readonly/constant variables (#2400) 2016-10-03 15:25:52 -07:00
Modules Added feature level test coverage to Registry provider (#2417) 2016-10-12 14:58:22 -07:00
Provider Move tests to more appropriate places now that we have the directory structure defined 2016-09-28 14:57:50 -07:00
SDK Add get-runspace -name test, remove runspace.close from AfterAll, dispose alone will suffice 2016-09-14 13:51:10 -07:00
README.md Correct link to Pester Do and Don't document 2016-08-19 11:29:50 -05:00

Pester Testing Test Guide

Also see the Pester Do and Don't document.

Running Pester Tests

Go to the top level of the PowerShell repository and run: Start-PSPester inside a self-hosted copy of PowerShell.

You can use Start-PSPester -Tests SomeTestSuite* to limit the tests run.

Testing new powershell processes

Any launch of a new powershell process must include -noprofile so that modified user and system profiles do not causes tests to fail. You also must take care to call the development copy of PowerShell, which is not the first one on the path.

Example:

    $powershell = Join-Path -Path $PsHome -ChildPath "powershell"
    & $powershell -noprofile -command "ExampleCommand" | Should Be "ExampleOutput"

Portability

Some tests simply must be tied to certain platforms. Use Pester's -Skip directive on an It statement to do this. For instance to run the test only on Windows:

It "Should do something on Windows" -Skip:($IsLinux -Or $IsOSX) { ... }

Or only on Linux and OS X:

It "Should do something on Linux" -Skip:$IsWindows { ... }

Pending

When writing a test that should pass, but does not, please do not skip or delete the test, but use It "Should Pass" -Pending to mark the test as pending, and file an issue on GitHub.