SlideShare a Scribd company logo
Mark Nash
Graduate Engineer at
DevOpsGuys
Ed Dipple
Senior Engineer at
DevOpsGuys
Plone conference 2007, Naples
$testFiles = Get-Item ".src*.Tests.ps1"
Invoke-Pester -Path $testFiles
Describing Dependency checking
Context Windows
[+] Should be able to add to the PATH variable 1.87s
Context Unix
[+] Should be able to add to the PATH variable 185ms
Context Mono is not installed
[+] Should throw exception if Mono not installed on Unix 186ms
[+] Should not throw exception if Mono not installed on Windows
125ms
Powershell Class
Create a fake
WebClient
Inline C# code
Import the FakeWebClient2 Class
# Call your function that uses the mock
1 -Scope It
}
$testFiles = Get-Item ".src*.tests.ps1"
Invoke-Pester -Path $testFiles
-OutputFormat NUnitXML
-OutputFile TestResults.xml
$testFiles = Get-Item ".src*.tests.ps1"
$sourceFiles = Get-Item ".src*.ps1" –Exclude *.Tests.ps1
Invoke-Pester -Path $testFiles
-CodeCoverage $sourceFiles
-CodeCoverageOutputFile coverage.xml
Unit Tests Functional Tests
• Test for expected output
values and exceptions
• Mock all commands that
change machine state
• Assert that mocks have
been called the
expected number of
times
• Test for actual state
change
• Minimal usage of Mock
objects
• Use TestDrive to isolate
state changes where
possible
Invoke-ScriptAnalyzer "./src"
Invoke-ScriptAnalyzer "./src" -Recurse
Get-ScriptAnalyzerRule
Describe 'PSScriptAnalyzer analysis' {
$ScriptAnalyzerResults = Invoke-ScriptAnalyzer
-Path "*.ps1"
-Severity Warning
It 'Should not return any violation' {
$ScriptAnalyzerResults | Should BeNullOrEmpty
}
}
https://github.com/MathieuBuisson/PowerShell-DevOps/
https://github.com/devopsguys/PSForge
https://github.com/devopsguys/FutureDecoded
https://blogs.technet.microsoft.com/heyscriptingguy/2015/12/16/unit-testing-
powershell-code-with-pester/
https://blogs.technet.microsoft.com/heyscriptingguy/2017/01/31/psscriptanaly
zer-deep-dive-part-1-of-4/

More Related Content

What's hot

What's hot (13)

An introduction to Jupyter notebooks and the Noteable service
An introduction to Jupyter notebooks and the Noteable serviceAn introduction to Jupyter notebooks and the Noteable service
An introduction to Jupyter notebooks and the Noteable service
 
Tech Talk #5 : Code Analysis SonarQube - Lương Trọng Nghĩa
Tech Talk #5 : Code Analysis SonarQube - Lương Trọng NghĩaTech Talk #5 : Code Analysis SonarQube - Lương Trọng Nghĩa
Tech Talk #5 : Code Analysis SonarQube - Lương Trọng Nghĩa
 
Top 50 .NET Interview Questions and Answers 2019 | Edureka
Top 50 .NET Interview Questions and Answers 2019 | EdurekaTop 50 .NET Interview Questions and Answers 2019 | Edureka
Top 50 .NET Interview Questions and Answers 2019 | Edureka
 
Sonar qube
Sonar qubeSonar qube
Sonar qube
 
String matching with finite state automata
String matching with finite state automataString matching with finite state automata
String matching with finite state automata
 
Go lang
Go langGo lang
Go lang
 
PART 1 - Python Tutorial | Variables and Data Types in Python
PART 1 - Python Tutorial | Variables and Data Types in PythonPART 1 - Python Tutorial | Variables and Data Types in Python
PART 1 - Python Tutorial | Variables and Data Types in Python
 
Python ppt.pptx
Python ppt.pptxPython ppt.pptx
Python ppt.pptx
 
Saying Goodbye to Quality Center
Saying Goodbye to Quality CenterSaying Goodbye to Quality Center
Saying Goodbye to Quality Center
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol Buffers
 
Web Accessibility Testing With Axe
Web Accessibility Testing With AxeWeb Accessibility Testing With Axe
Web Accessibility Testing With Axe
 
Hacktoberfest 2022
Hacktoberfest 2022Hacktoberfest 2022
Hacktoberfest 2022
 
Practical Sikuli: using screenshots for GUI automation and testing
Practical Sikuli: using screenshots for GUI automation and testingPractical Sikuli: using screenshots for GUI automation and testing
Practical Sikuli: using screenshots for GUI automation and testing
 

Similar to Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Future Decoded 2017

Real world cross-platform testing
Real world cross-platform testingReal world cross-platform testing
Real world cross-platform testing
Peter Edwards
 
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
RahulRoy130127
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
Michelangelo van Dam
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnit
varuntaliyan
 

Similar to Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Future Decoded 2017 (20)

Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
 
Agile Swift
Agile SwiftAgile Swift
Agile Swift
 
Real world cross-platform testing
Real world cross-platform testingReal world cross-platform testing
Real world cross-platform testing
 
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
 
Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in python
 
PHPunit and you
PHPunit and youPHPunit and you
PHPunit and you
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
Python testing
Python  testingPython  testing
Python testing
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Unit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentUnit Testing from Setup to Deployment
Unit Testing from Setup to Deployment
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Simpletest - A beginners guide
Simpletest - A beginners guideSimpletest - A beginners guide
Simpletest - A beginners guide
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnit
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
 
#dddsw - Modernizing .NET Apps with Docker
#dddsw - Modernizing .NET Apps with Docker#dddsw - Modernizing .NET Apps with Docker
#dddsw - Modernizing .NET Apps with Docker
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS
 

More from DevOpsGroup

More from DevOpsGroup (20)

DevOpsGroup Cloud Adoption Frameworks - agile south coast
DevOpsGroup Cloud Adoption Frameworks - agile south coastDevOpsGroup Cloud Adoption Frameworks - agile south coast
DevOpsGroup Cloud Adoption Frameworks - agile south coast
 
WinOps - Lessons learned from Enterprise DevOps with Microsoft technologies ...
WinOps - Lessons learned from Enterprise DevOps with Microsoft technologies  ...WinOps - Lessons learned from Enterprise DevOps with Microsoft technologies  ...
WinOps - Lessons learned from Enterprise DevOps with Microsoft technologies ...
 
WinOps - Lessons learned from Enterprise DevOps with Microsoft technologies
WinOps - Lessons learned from Enterprise DevOps with Microsoft technologies WinOps - Lessons learned from Enterprise DevOps with Microsoft technologies
WinOps - Lessons learned from Enterprise DevOps with Microsoft technologies
 
DevOpsGuys Scaling DevOps @ #CIOWaterCooler - June 2018
DevOpsGuys Scaling DevOps @ #CIOWaterCooler - June 2018DevOpsGuys Scaling DevOps @ #CIOWaterCooler - June 2018
DevOpsGuys Scaling DevOps @ #CIOWaterCooler - June 2018
 
DevOpsGuys - Cloud Adoption Frameworks - IPExpo April 2018
DevOpsGuys - Cloud Adoption Frameworks - IPExpo April 2018DevOpsGuys - Cloud Adoption Frameworks - IPExpo April 2018
DevOpsGuys - Cloud Adoption Frameworks - IPExpo April 2018
 
The future of (Windows) operations #WinOps #DevOps
The future of (Windows) operations #WinOps #DevOpsThe future of (Windows) operations #WinOps #DevOps
The future of (Windows) operations #WinOps #DevOps
 
Why Culture eats DevOps for Breakfast
Why Culture eats DevOps for BreakfastWhy Culture eats DevOps for Breakfast
Why Culture eats DevOps for Breakfast
 
DevOpsGuys - DevOps Automation - The Good, The Bad and The Ugly
DevOpsGuys - DevOps Automation - The Good, The Bad and The UglyDevOpsGuys - DevOps Automation - The Good, The Bad and The Ugly
DevOpsGuys - DevOps Automation - The Good, The Bad and The Ugly
 
Why #DevOps Transformation has to start with you
Why #DevOps Transformation has to start with youWhy #DevOps Transformation has to start with you
Why #DevOps Transformation has to start with you
 
DevOpsGuys - How to get started with DevOps - Redgate Webinar April 2017
DevOpsGuys - How to get started with DevOps - Redgate Webinar April 2017DevOpsGuys - How to get started with DevOps - Redgate Webinar April 2017
DevOpsGuys - How to get started with DevOps - Redgate Webinar April 2017
 
DevOpsGuys - Getting Started with DevOps - Github/Azure Webinar
DevOpsGuys - Getting Started with DevOps - Github/Azure WebinarDevOpsGuys - Getting Started with DevOps - Github/Azure Webinar
DevOpsGuys - Getting Started with DevOps - Github/Azure Webinar
 
Maximising the value of the Cloud through DevOps
Maximising the value of the Cloud through DevOpsMaximising the value of the Cloud through DevOps
Maximising the value of the Cloud through DevOps
 
DevOpsGuys FutureDecoded 2016 - is DevOps the Answer
DevOpsGuys FutureDecoded 2016 - is DevOps the AnswerDevOpsGuys FutureDecoded 2016 - is DevOps the Answer
DevOpsGuys FutureDecoded 2016 - is DevOps the Answer
 
Building for DevOps Success
Building for DevOps SuccessBuilding for DevOps Success
Building for DevOps Success
 
DevOps is the Answer... What was the question again? DevOps and Digital Trans...
DevOps is the Answer... What was the question again? DevOps and Digital Trans...DevOps is the Answer... What was the question again? DevOps and Digital Trans...
DevOps is the Answer... What was the question again? DevOps and Digital Trans...
 
WinOps meetup April 2016 DevOps lessons from Microsoft \\Build\
WinOps meetup April 2016   DevOps lessons from Microsoft \\Build\WinOps meetup April 2016   DevOps lessons from Microsoft \\Build\
WinOps meetup April 2016 DevOps lessons from Microsoft \\Build\
 
Continuous delivery for databases - Bristol DevOps Edition
Continuous delivery for databases - Bristol DevOps EditionContinuous delivery for databases - Bristol DevOps Edition
Continuous delivery for databases - Bristol DevOps Edition
 
Delivering DevOps Automation on Windows
Delivering DevOps Automation on WindowsDelivering DevOps Automation on Windows
Delivering DevOps Automation on Windows
 
Continuous delivery for databases
Continuous delivery for databasesContinuous delivery for databases
Continuous delivery for databases
 
#DevOps in a windows world - @DevOpsGuys
#DevOps in a windows world - @DevOpsGuys#DevOps in a windows world - @DevOpsGuys
#DevOps in a windows world - @DevOpsGuys
 

Recently uploaded

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 

Recently uploaded (20)

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 

Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Future Decoded 2017

Editor's Notes

  1. Assume the audience knows Powershell well (sysadmins) Tell the audience this
  2. You should assume that until your unit tests pass, whatever wonderful feature implemented has broken sometime else. Developers for an enterprise CMS
  3. It is the Pester convention that test file names should end in ".Tests.ps1"
  4. "Exactly" assertions are case sensitive
  5. You will need the latest version of Pester for this