PowerShell/test/powershell
Yanbing edb292face Add tests for the Language (#2118)
DeserializedMethods, DeserializedTypeConversion,
DynamicParameters, Generics, Indexer, LindEndings, MyInvocation,
OrderedAttributeForHashTable.
2016-09-15 11:27:44 -07:00
..
Common address some review feedback 2016-08-30 16:15:10 -07:00
engine Minor improvements to SSH remoting cmdlets (#2249) 2016-09-14 15:13:10 -07:00
enginecore Add more sxs module path tests and make the basic sxs module test run on both powershell core and windows powershell 2016-09-14 15:19:12 -07:00
Host Fix for Linux remote script debugging hang (#2213) 2016-09-13 11:31:48 -07:00
Language Add tests for the Language (#2118) 2016-09-15 11:27:44 -07:00
Modules Adding ported LocalAccounts tests 2016-09-14 17:18:13 -07:00
Scripting/NativeExecution Use a variable instead of a file for testing args 2016-09-13 13:37:42 -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.