Running Pester Tests in Parallel
I’m working on a project which uses pester tests to validate our deployment and system health.
We’ve accumulated a lot of tests. Nearly all of these sit and wait on things to happen in the deployment and we’re running them sequentially which takes around 20mins. Each of our tests is in it’s own file.
What I wanted to do was, as these are IO bound tests waiting on things to trip in the environment or polling http endpoints, run them all in parallel. One file per thead or something similar.
This issue discusses this topic. I took a lead from the Invoke-Parallel
snipped and started playing, unfortunately the output from the tests was mangled and overlapping.
Then I realised I could use Powershell Jobs to schedule the work and poll for the job to be completed then receive each jobs to have to output displayed nicely.
So now the output looks good:
Note: We’re using Pester v4 you’ll have to do a little bit of fiddling to port to Pester 5
https://gist.github.com/lawrencegripper/3428970a5be6e1c5e62a13b22e639cd9
Here is the full repro: https://github.com/lawrencegripper/hack-parallelpester