I am lookin for a unit testing framework of type xUnit that lets me test PowerShell functions with PowerShell scripts.
Pester is a test framework meant for PowerShell and is a module you can install. It has several features: Assertions. Pester comes with diverse ways of asserting conditions that will determine if your tests should fail or not.
Jest. Jest was the most popular JavaScript unit testing framework in 2020. For web apps that are based on React, Jest is the preferred framework. Apart from React, Jest supports unit testing of Angular, VueJS, NodeJS, and others.
To build a Pester test, you need, at a minimum, two files: a PS1 script which contains code to test and a test script file. Create a folder called Pester101 somewhere, a PS1 script called Pester101. ps1 and an associated test script file called Pester101. Tests.
Unit tests give developers and testers a quick way to look for logic errors in the methods of classes in C#, Visual Basic, and C++ projects.
Well, just for completeness: There is actually PSUnit. Doesn't seem to be very mature, though as I see only two spikes of activity since its beginning as well as no documentation to speak of.
But as I learnt from cuTest, unit testing is something that fits into a very small space (at least for C in that case), so having something that works might not require too much effort.
While not an actual framework a la xUnit, Lee Holmes did write an article about how to unit test PowerShell using PowerShell scripts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With