

This might require you to set up a more complicated test environment, so the necessary web services, for example, are available. Instead of isolating your code from the other parts, you run everything in all its glory, and make sure it’s behaving properly when all of the bits are working together. Integration tests are pretty much the opposite of unit tests.

These dependencies could be anything, including a web service of some sort, the state of the computer where the script runs, or even calls to other PowerShell functions or cmdlets. If the function you are testing depends on anything other than the parameters that are passed in, you’ll want to isolate your code from those other dependencies in the unit test. Unit tests are responsible for verifying the behavior of a single unit of code, which in PowerShell, typically means a function. It can usually be executed on the developer’s machine before checking in the code to source control. For the purposes of Windows PowerShell code, I tend to refer to three:Ī unit test is the smallest and fastest type, and it is the first thing that will be run in your pipeline. There are several categories of automated testing, all of which are used in a continuous delivery pipeline. Use Pester for testing PowerShell modulesīefore we get into the technical details today, let’s define a few terms. Use Pester to analyze small pieces of Windows PowerShell code Unit Testing PowerShell Code with Pester.
Pester testing how to#
Learn how to get information back from Pester

Learn about a new test framework for PowerShell called Pester Note This is a five-part series that includes the following posts: Summary: Guest blogger, Dave Wyatt, discusses using Pester to analyze small pieces of Windows PowerShell code.
