More Pester Testing .NET with Copilot
Last time, I started exploring how to build a set of Pester tests for code written around the .NET Framework. I am using the Get-OSDetail
function that uses raw .NET classes for CIM objects. In the previous article, I shared the process I used to build the Pester test with the assistance of GitHub CoPilot in VS Code. If you read the last article, you know the AI-generated code is far from perfect. You still have to understand how to write a Pester test. However, Copilot accelerated the process and provided a good starting point in many cases.
Organizing the Pester Tests
When we left off, I had a test that would validate the function's design and input. When Copilot created a test for the CimSession
parameter, it kindly organized the test in a Context
block. I often like to organize my tests in this way. It makes it easier to understand the test's purpose and selectively run tests.