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.
Thank you for clearing that up. I kept thinking I was missing something, I'm just going to need to get creative in creating test or just focus on on testing the most important logic. It's nice to get an answer from the person that wrote a lot of the current Pester code. Thanks Dave