PowerShell/test/powershell
Aditya Patwardhan 877c193af0 Add RequireAdminOnWindows tag for install-package tests (#2390)
Add the tag RequireAdminOnWindows tags so that these tests do not fail on
daily builds.
2016-09-29 18:13:33 -07:00
..
Common Fix Get-Credential to not prompt twice when no parameter is specified 2016-09-27 09:49:28 -07:00
engine Add 'RequireAdminOnWindows' tag to some tests suites 2016-09-29 12:29:27 -07:00
Host Merge pull request #2336 from lzybkr/stdin_fixes 2016-09-27 11:20:43 -07:00
Language Move tests to more appropriate places now that we have the directory structure defined 2016-09-28 14:57:50 -07:00
Modules Add RequireAdminOnWindows tag for install-package tests (#2390) 2016-09-29 18:13:33 -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.