The v5.6.164 service build introduces Pester integration into PowerShell Studio. For those who are not familiar with the Pester module, it is a testing framework for PowerShell. The module allows you to run unit tests on your scripts and functions. I will not go into detail into the Pester module itself. There are plenty of articles covering Pester (see Related Links below).
Run Pester Tests
We added the new Run Pester Test (Ctrl + Shift + F8) command to the ribbon’s Run menu:
You can also access Run Pester Test by using the document tab context menu:
Important: At this time, the Run Pester Test command only supports individual ps1 files. In other words, it doesn’t run a test against a psf file.
How does it work?
The Run Pester Test command will invoke the associated Pester test script for the active ps1 script file.
Pester defines a test script with the *.Tests.ps1 extension. For example, if you have a script named:
The associated Pester test file should be:
The *.Tests.ps1 files contain all of your Pester tests that will be executed when you run the Run Pester Test command:
Note: PowerShell Studio does not require you to dot source the source file within the *.Tests.ps1 script. It will automatically dot source the original file for you when you use the Run Pester Test command.
If there isn’t an associated pester test script, you will get an error message:
When a Pester test script is found, the results are displayed in the Tools Output panel:
Pester uses symbols to denote each individual result. Here is a summary of what each symbol means:
The test totals are reflected at the bottom of the results:
You can double-click on the Description, Context or Test name to quickly jump to that location within the *.Tests.ps1 script.
Since the Pester results are displayed in the Tools Output panel, you can take advantage of the Copy HTML functionality:
Future Pester Features
We plan on expanding our Pester support for PowerShell Studio. Your feedback is very important to us. Please let us know what Pester features you would like to us implement next by submitting a feature request here.
You can view the complete service build log here.
Please continue providing your feedback. Many of the new features included in the service builds are suggestions from users like you. Submit your suggestions or feature requests on the Wish List and Feature Requests forum or the Feature Requests page.