Now that I have some simple functions and some tests in my master branch on Github, I want to make sure the tests are executed (and pass!) every time I merge some new code. At this point I do not care too much about my dev branch because I know I’ll commit often and things will not always be stable, but I’ll make sure all my test will pass before I merge from dev to master (and later I way want to publish from master to the Powershell Gallery, but only if all tests pass of course!). The first thing I need is an account on Azure DevOps (you can start with a free account) and when ready, head to Pipelines then Builds: Since my code is in Github, that’s what I’ll choose: The first time we setup this integration, Azure Pipelines must be authorized to access Github: Since I don’t have a yaml file already, I’ll select Starter pipeline At this point in my tests things got a bit murky. The Azure Devops Marketplace has (as of this post) two free extensions to run Pester tasks so I decided to try them. I installed both extensions and added them…
-
-
Test Azure custom modules with Pester
Before I go too far along with building my LSECosmos module I must add proper tests. Just as a quick refresher (or to get some context if you’re not familiar with the concept), here are some pointers about Test Driven Development and Unit Testing: Test Driven Development (Wikipedia) Unit Testing (Wikipedia) Software Testing Fundamentals While it is relatively straightforward to test simple scripts (we would likely manually run the script testing a 2-3 core scenarios to make sure nothing terrible happens), things can get complicated fairly quickly with longer scripts or modules, especially when they are using a variety of cmdlets to take actions (think about Azure resources for example, or any other system-wide on-prem operation), need to pass data and objects back and forth between calls and so on. If you have written enough lines of code (no matter the language/tool you use), I bet you can remember at least one occasion where you decided to make an apparently small and innocent change to a well working piece of software an all hell broke loose 😵. I recently came across this meme on Facebook, it sums it up nicely 😅 (thanks to CodeChef for sharing): At its core proper…