PowerShell/test/powershell
James Truher [MSFT] 3f99de5784 Added tests to close code coverage in CIM area (#2528)
* Added tests to close code coverage in CIM area

Added CimAdapter.Tests for adaptation layer (code cribbed from BVT tests)
Added SessionOption.Tests.ps1 (Code cribbed from BVT tests)
Modified CimClass tests by adding more tests
Added CimSession.Tests for basic tests of New-CimSession cmdlet
Added CimInstance.Tests for basic tests of Get-CimInstance

* Add CI tags to tests

* unify test execution to use try/catch for marking tests as skipped

moved test which retrieves cimclass via method to feature as it is not
a common operation, this test can take some time as well
2016-11-17 11:46:07 -08:00
..
Common Refactor implicit remoting tests to work in CI 2016-10-28 16:51:44 -07:00
engine Added tests to close code coverage in CIM area (#2528) 2016-11-17 11:46:07 -08:00
Host Re-shuffle minishell tests 2016-11-15 14:49:39 -08:00
Language Trying to make 'native command lifecycle' test unflaky 2016-11-15 14:49:39 -08:00
Modules Added tests to close code coverage in CIM area (#2528) 2016-11-17 11:46:07 -08: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 Replace 'git rev-parse' with path relative to '$PSScriptRoot' in powershell tests 2016-10-28 16:51:44 -07:00
README.md Fixed broken link in README (#2643) 2016-11-08 10:22:26 -08:00

Pester Testing Test Guide

Also see the Writing Pester Tests 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.