I’ve been trying to use pester to start automating test of my PowerShell scripts but keep getting stuck. I think a lot of it is due to the design of my scripts not being as testable as they should be. All of the examples that I see for Pester is basically testing a library of functions. What about testing a controller script is that possible? Or should you just test the helper functions of the controller script that is stored in ps1 or module files? It seems to me that Pester is great for testing individual functions, but can’t figure out how to use for testing the logic of a controller script since pester has to load the script first, this causes the controller script to then run.
If anyone can give me pointers I would appreciate it. I have watched 2 sessions from Dave Wyatt on pester, one was “Beyond Syntax: Pester Testing”, and another was a recording from the 2015 PowerShell summit I think. I have also read countless blogs on the subject to include reading the GitHub examples on Pester, but still can’t quite figure out how to apply it to my scripts.