[+] Title Should Be 'Introduction to Pester‘ 89ms Describing SQLSatHolland Presentation Context Presentation [+] Title Should Be 'Introduction to Pester‘ 89ms [+] Should have many Demos 8ms Context Speaker [+] Name should be Rob Sewell 51ms [+] Twitter Should be @sqldbawithbeard 19ms [+] Website Should be sqldbawithAbeard.com 12ms Context Audience [+] Audience should be awesome 60ms [!] They should not fall asleep 7ms
speaker questionnaire Name : Rob Occupation : DBA, Automator, Do-er, Trainer, DevOpser! Available for hire - RobSewell.info Interests : PowerShell, Automation And SQL (PaaS geddit?) Interesting Fact : Beard. (Still) Plays Cricket, Flies Drone Speaker : PsConfEU, PsConfAsia, PSSaturdays, PSMondays, User Groups PowerShell and SQL Community : PowerShell VG, PowerShell Conference EU Organiser, PSDayUK Organiser, SQL South West , SQL Sat Exeter , dbareports, dbatools, SQLDiagAPI, MVP Crashes
Invoke-SponsorVisit
What is Pester? Pester provides a framework for running unit tests to execute and validate PowerShell commands from within PowerShell https://github.com/pester/Pester
Why Test? Good tests can… Verify the code is working correctly Prevent future regressions Document the code’s behaviour Provide design guidance Support refactoring https://www.devmynd.com/blog/five-factor-testing/ Does it do what I want If I change it does it do what I want What is it supposed to do This is how it is designed Does it still do what we want when we make big changes
How Do I Get Pester? If you have PowerShell V5 or above you already have it. You should update it using Install-Module Pester -Force If Not Install-Module Pester (use –Scope CurrentUser if not admin)
Invoke-SponsorVisit –Repeat Please add this slide in your presentation
What does Pester Look Like?
Environmental Validation As Pester is just PowerShell you can use it to validate the results of any PowerShell command This is BRILLIANT for validating your environment
How Do I Start? Hey Beardy ! MUST BE TIME FOR A DEMO
Two things we didnt show Test Drive A drive created in $ENV:Temp that is accessible via $TestDrive and exists within the scope of a Describe block In ModuleScope This tells Pester to inject the mock into the module's scope, which causes any calls to those commands from inside the module to execute the mock instead.
Questions? Rob Sewell - @SQLDBAWithBeard SQLDBAWithABeard.com You should get the Pester Book by Adam Bertram https://leanpub.com/pesterbook Rob Sewell - @SQLDBAWithBeard SQLDBAWithABeard.com
Start-SpeakerEvaluation