PowerShell/test/powershell
2016-09-27 09:49:28 -07:00
..
Common Fix Get-Credential to not prompt twice when no parameter is specified 2016-09-27 09:49:28 -07:00
engine Minor improvements to SSH remoting cmdlets (#2249) 2016-09-14 15:13:10 -07:00
enginecore Add test coverage for Command discovery and requires (#2285) 2016-09-26 13:36:04 -07:00
Host Fix binary operator tab completion (#2338) 2016-09-22 11:56:38 -07:00
Language Add test coverage for Command discovery and requires (#2285) 2016-09-26 13:36:04 -07:00
Modules Fix Get-Credential to not prompt twice when no parameter is specified 2016-09-27 09:49:28 -07:00
SDK add runspace.dispose to clean up created runspace 2016-09-14 13:58:21 -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.