PowerShell/test/powershell/README.md

53 lines
1.5 KiB
Markdown
Raw Normal View History

2016-03-31 00:42:16 +02:00
Pester Testing Test Guide
=========================
2015-09-30 23:37:37 +02:00
2016-11-08 19:22:26 +01:00
Also see the [Writing Pester Tests](../../docs/testing-guidelines/WritingPesterTests.md)
document.
2016-04-22 00:49:29 +02:00
Running Pester Tests
--------------------
2015-09-30 23:43:18 +02:00
2016-04-22 00:49:29 +02:00
Go to the top level of the PowerShell repository and run: `Start-PSPester`
inside a self-hosted copy of PowerShell.
2015-10-01 00:19:55 +02:00
2016-04-22 00:49:29 +02:00
You can use `Start-PSPester -Tests SomeTestSuite*` to limit the tests run.
2015-10-01 00:19:55 +02:00
2016-04-22 00:49:29 +02:00
Testing new `powershell` processes
----------------------------------
2015-10-01 00:19:55 +02:00
2016-04-22 00:49:29 +02:00
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.
2016-03-31 00:42:16 +02:00
2016-04-22 00:49:29 +02:00
Example:
```powershell
$powershell = Join-Path -Path $PsHome -ChildPath "powershell"
& $powershell -noprofile -command "ExampleCommand" | Should Be "ExampleOutput"
```
Portability
-----------
2016-03-31 00:42:16 +02:00
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:
```powershell
It "Should do something on Windows" -Skip:($IsLinux -Or $IsOSX) { ... }
```
Or only on Linux and OS X:
```powershell
It "Should do something on Linux" -Skip:$IsWindows { ... }
```
2015-10-01 00:19:55 +02:00
2016-04-22 00:49:29 +02:00
Pending
-------
2016-03-31 00:42:16 +02:00
2016-04-22 00:49:29 +02:00
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.