SlideShare a Scribd company logo
Automated Testing 
but like 
For PowerShell 
Rob Reynolds
Automated Testing but like for PowerShell (April 2012)
Who am I? Who cares… 
• Rob Reynolds 
• Technical Lead for VML 
• OSS 
– Chocolatey / Chuck Norris Framework / NuGet 
– Various contributions to other projects 
• ferventcoder – twitter, gmail, you name it 
• ferventcoder.com / Devlicio.us 
• Automated Testing for 8 years
Topics d 
• Automated Testing… 
– Integration Testing 
– Mocking 
– Unit Testing 
• Behavior Driven 
Development… 
– What does it all mean? 
• ..but like for PowerShell? 
– Pester 
Entire presentation w/examples: 
http://bit.ly/powershellbdd
Back to Basics
Test Automation 
• Test automation is the use of software to 
control the execution of tests, the comparison 
of actual outcomes to predicted outcomes, 
the setting up of test preconditions, and other 
test control and test reporting 
functions.[1] Commonly, test automation 
involves automating a manual process already 
in place that uses a formalized testing process. 
• -Wikipedia
So what is test automation? 
• Making executable tests to determine your 
software works appropriately
Fallacies of automated testing 
• “Automated tests will prove the absence of 
bugs” 
• “’Unit’ testing is easy” 
• “One class – one test class” 
• “Testing takes little time”
Automated Testing but like for PowerShell (April 2012)
Why do automated testing? 
• “We never touch that piece of code. A guy 
wrote it a long time ago and he’s not here 
anymore. It just works.” 
– Translation “We have no idea WTF it does and 
have no test automation on it to help us figure it 
out.”
So why do automated testing? 
• Maintenance – change is a constant 
• Feedback cycles 
• Scenarios / edge cases 
• Gives you confidence in the code 
– Works appropriately
What are the types of automated 
tests? 
• White box (MSTest / Nunit / xUnit / MbUnit) 
– Unit 
– Integration 
• Functionality – Groups of functionality 
• Database Tests 
• Black box (FitNesse) 
– End 2 End – System Integration Testing 
• Performance testing
What are the types of automated 
tests? 
• White box (MSTest / Nunit / xUnit / MbUnit) 
– Unit 
– Integration 
• Functionality – Groups of functionality 
• Database Tests 
• Black box (FitNesse) 
– End 2 End – System Integration Testing 
• Performance testing
What are the types of automated 
tests? 
• White box 
– Unit 
– Integration 
• Functionality – Groups of functionality 
• Database Tests 
Why do we categorize? Is it because we are just 
developers and everything has a place?
Reasons for categorization 
• Feedback cycles 
• Maintenance 
• “The more units put into something the 
greater the feedback cycle and the less 
maintainable the test.”
Unit Testing 
• Test a “unit” of something 
• But WTF is a unit? 
– A near religion around this 
• For purposes of discussion a unit is one class / 
sometimes one method in code
Integration Testing 
• Integration 
– Functionality – Groups of functionality 
– Database Tests 
“Anything that tests more than one unit as part 
of the same test is an integration”
But wait, couldn’t that mean all tests 
are integration?
Integration Testing 
• Integration 
– Functionality – Groups of functionality 
– Database Tests 
“Anything that tests more than one unit as part 
of the same test is an integration” 
Yes, most tests we write are a blend of unit and 
integration but we strive for unit testing
Demo
Where does Mocking come in?
Where does mocking come in? 
• Fakes, mocks, stubs – oh my! 
– Dummies - objects are passed around but never 
used 
– Fake - working implementations with possible 
shortcuts 
– Stubs - provide canned answers (answer state 
questions) 
– Mocks - objects with you can set expectations and 
verify behavior on 
• Known as test doubles
Test Doubles – is it okay to blend? 
• Most of us never write a true 
stub/fake/mock/etc but something that 
blends ideas from each of these
Behavior Driven Development…
This is not BDD… 
• ...but the style of writing for your tests in a 
natural language 
• BDD can be a religious battle and this talk is 
not about that (check out Dan North for more 
info) 
• Describe behaviors and interactions 
• Think not about “tests” but about behaviors 
and specifications
Demo
…but like for PowerShell
Meet Pester 
• https://github.com/scottmuc/Pester 
• BDD style of test writing
Demo
But is Pester enough? 
• Does not get you to unit testing alone 
• Does no mocking/stubbing
How to get there 
• A little ingenuity 
• Maybe a mocking/stub framework for 
PowerShell in the future – what would you 
name it? 
– PowerMock? 
– PSomething 
– PShellshock
PowerShell Unit Testing 
• A PowerShell unit is a function 
• Functions can be overwritten by scoping a 
function of the same name
PowerShell Stubbing 
• Functions can be overwritten by a function of 
the same name and parameters 
• This allows you to interrupt and stub the 
functionality 
• “I want behavior verification. I want my mock”
PowerShell Mocking 
• After you have implemented the stubs you 
allow different behaviors to be returned 
through conventional properties and flags
Demo
Questions? 
• ferventcoder – twitter, gmail, etc 
• Pester – 
https://github.com/scottmuc/Pester#readme 
• Chocolatey – http://chocolatey.org 
• Mocks aren’t stubs - 
http://martinfowler.com/articles/mocksArentS 
tubs.html
Automated Testing but like for PowerShell (April 2012)

More Related Content

What's hot (20)

PDF
Making cross browser tests beautiful
Meaghan Lewis
 
PPTX
Continuous Integration: Finding problems soonest
Shawn Jones
 
PDF
The Cowardly Test-o-Phobe's Guide To Testing
Tim Duckett
 
PDF
Unit testing
Brian Hu
 
PPTX
Presentation delex
Alexander Pushkarev
 
PPT
Next generation frontend tooling
pksjce
 
PDF
Automated testing
Aiste Stikliute
 
PDF
Jest: Frontend Testing leicht gemacht @EnterJS2018
Holger Grosse-Plankermann
 
PPT
Walking Skeleton
hepphep
 
PPTX
Как стать синьором
COMAQA.BY
 
PPTX
Sql server baselines
Mike Walsh
 
PPTX
How does Java 8 exert hidden power on Test Automation?
Sergey Korol
 
PPT
Test Driven Development using QUnit
satejsahu
 
PPT
Unit Testing, TDD and the Walking Skeleton
Seb Rose
 
PPTX
Protractor training
Sergiy Stotskiy
 
PPTX
TDD for DB integration
Mikalai Alimenkou
 
PDF
Unit Testing in JavaScript
Rob Scaduto
 
PPTX
Selenium + Specflow
cromwellryan
 
PDF
Dave Haeffner's Proven Method to Grading the Quality of Selenium Tests
Applitools
 
PPTX
Automated Testing: Obstacles, Pitfalls, and Dangers
Stephen Ritchie
 
Making cross browser tests beautiful
Meaghan Lewis
 
Continuous Integration: Finding problems soonest
Shawn Jones
 
The Cowardly Test-o-Phobe's Guide To Testing
Tim Duckett
 
Unit testing
Brian Hu
 
Presentation delex
Alexander Pushkarev
 
Next generation frontend tooling
pksjce
 
Automated testing
Aiste Stikliute
 
Jest: Frontend Testing leicht gemacht @EnterJS2018
Holger Grosse-Plankermann
 
Walking Skeleton
hepphep
 
Как стать синьором
COMAQA.BY
 
Sql server baselines
Mike Walsh
 
How does Java 8 exert hidden power on Test Automation?
Sergey Korol
 
Test Driven Development using QUnit
satejsahu
 
Unit Testing, TDD and the Walking Skeleton
Seb Rose
 
Protractor training
Sergiy Stotskiy
 
TDD for DB integration
Mikalai Alimenkou
 
Unit Testing in JavaScript
Rob Scaduto
 
Selenium + Specflow
cromwellryan
 
Dave Haeffner's Proven Method to Grading the Quality of Selenium Tests
Applitools
 
Automated Testing: Obstacles, Pitfalls, and Dangers
Stephen Ritchie
 

Similar to Automated Testing but like for PowerShell (April 2012) (20)

PPTX
Techorama 2017 - Testing the unit, and beyond.
Bert Brouns
 
PPTX
Skillwise Unit Testing
Skillwise Group
 
PPT
Automated testing 101
Tabitha Chapman
 
PPTX
Automated tests
Damian Sromek
 
PPTX
Unit Testing talk
Sergei Kukharev
 
PPTX
Testing 101
Noam Barkai
 
PDF
Unit testing - An introduction
Alejandro Claro Mosqueda
 
PPTX
Test-Driven Development
John Blum
 
PPT
Automated testing overview
Alex Pop
 
PDF
Testing - How Vital and How Easy to use
Uma Ghotikar
 
PDF
Agile Testing Pasadena JUG Aug2009
Grig Gheorghiu
 
PPTX
The Test way
Mikhail Grinfeld
 
PDF
Unit Testing
Scott Leberknight
 
PPT
Testing and Mocking Object - The Art of Mocking.
Deepak Singhvi
 
KEY
Unit Testing Your Application
Paladin Web Services
 
PPTX
Binary Studio Academy: .NET Code Testing
Binary Studio
 
PDF
Test Driven Development
ZendCon
 
PPTX
Software presentation
JennaPrengle
 
PPTX
TEST AUTOMATION: AKA QUALITY CONTROL
SovTech (Scrums.com)
 
PPTX
TEST AUTOMATION: AKA QUALITY CONTROL
Nyarai Tinashe Gomiwa
 
Techorama 2017 - Testing the unit, and beyond.
Bert Brouns
 
Skillwise Unit Testing
Skillwise Group
 
Automated testing 101
Tabitha Chapman
 
Automated tests
Damian Sromek
 
Unit Testing talk
Sergei Kukharev
 
Testing 101
Noam Barkai
 
Unit testing - An introduction
Alejandro Claro Mosqueda
 
Test-Driven Development
John Blum
 
Automated testing overview
Alex Pop
 
Testing - How Vital and How Easy to use
Uma Ghotikar
 
Agile Testing Pasadena JUG Aug2009
Grig Gheorghiu
 
The Test way
Mikhail Grinfeld
 
Unit Testing
Scott Leberknight
 
Testing and Mocking Object - The Art of Mocking.
Deepak Singhvi
 
Unit Testing Your Application
Paladin Web Services
 
Binary Studio Academy: .NET Code Testing
Binary Studio
 
Test Driven Development
ZendCon
 
Software presentation
JennaPrengle
 
TEST AUTOMATION: AKA QUALITY CONTROL
SovTech (Scrums.com)
 
TEST AUTOMATION: AKA QUALITY CONTROL
Nyarai Tinashe Gomiwa
 
Ad

More from Rob Reynolds (20)

PDF
Chocolatey for Organizations: Easily Manage Software - PowerShell Summit 2019
Rob Reynolds
 
PDF
Chocolatey - Software Automation for Windows (and sneak peak of Central Mana...
Rob Reynolds
 
PDF
Modern Software Management on Windows with Chocolatey and Puppet
Rob Reynolds
 
PDF
Chocolatey + DSC = Software Automation Sweeter - PowerShell Day UK
Rob Reynolds
 
PDF
Modern Software Management on Windows w/Chocolatey
Rob Reynolds
 
PDF
Chocolatey + Artifactory = A Sweet Solution for Managing Windows
Rob Reynolds
 
PDF
Modern Software Management on Windows w/Chocolatey - That Conference 2017
Rob Reynolds
 
PDF
Modern Software Management on Windows with Chocolatey - Automation Management...
Rob Reynolds
 
PDF
Software Management with PowerShell DSC and Chocolatey - PowerShell Summit 2017
Rob Reynolds
 
PDF
Easily Manage Software on Windows with Chocolatey - PuppetConf 2016
Rob Reynolds
 
PPTX
Running a Successful Open Source Project
Rob Reynolds
 
PDF
Windows Just Got Chocolatey (Package Management) LISA15
Rob Reynolds
 
PDF
Puppet On Windows - Puppet Camp DC 2015
Rob Reynolds
 
PDF
Chocolatey and Puppet: Managing Your Windows Software Since 2011
Rob Reynolds
 
PDF
DevOps: What is This Puppet You Speak Of?
Rob Reynolds
 
PDF
Chocolatey Goodness: From Fringe to Mainstream #dotnetfringe
Rob Reynolds
 
PDF
Plugging Chocolatey into your Puppet Infrastructure PuppetConf2014
Rob Reynolds
 
PDF
DevOps: Using Vagrant to Enhance Your Day to Day Development
Rob Reynolds
 
PDF
DevOps: Getting Started with Puppet on Windows
Rob Reynolds
 
PDF
Puppet on Windows: Now You're Getting Chocolatey PuppetConf2013
Rob Reynolds
 
Chocolatey for Organizations: Easily Manage Software - PowerShell Summit 2019
Rob Reynolds
 
Chocolatey - Software Automation for Windows (and sneak peak of Central Mana...
Rob Reynolds
 
Modern Software Management on Windows with Chocolatey and Puppet
Rob Reynolds
 
Chocolatey + DSC = Software Automation Sweeter - PowerShell Day UK
Rob Reynolds
 
Modern Software Management on Windows w/Chocolatey
Rob Reynolds
 
Chocolatey + Artifactory = A Sweet Solution for Managing Windows
Rob Reynolds
 
Modern Software Management on Windows w/Chocolatey - That Conference 2017
Rob Reynolds
 
Modern Software Management on Windows with Chocolatey - Automation Management...
Rob Reynolds
 
Software Management with PowerShell DSC and Chocolatey - PowerShell Summit 2017
Rob Reynolds
 
Easily Manage Software on Windows with Chocolatey - PuppetConf 2016
Rob Reynolds
 
Running a Successful Open Source Project
Rob Reynolds
 
Windows Just Got Chocolatey (Package Management) LISA15
Rob Reynolds
 
Puppet On Windows - Puppet Camp DC 2015
Rob Reynolds
 
Chocolatey and Puppet: Managing Your Windows Software Since 2011
Rob Reynolds
 
DevOps: What is This Puppet You Speak Of?
Rob Reynolds
 
Chocolatey Goodness: From Fringe to Mainstream #dotnetfringe
Rob Reynolds
 
Plugging Chocolatey into your Puppet Infrastructure PuppetConf2014
Rob Reynolds
 
DevOps: Using Vagrant to Enhance Your Day to Day Development
Rob Reynolds
 
DevOps: Getting Started with Puppet on Windows
Rob Reynolds
 
Puppet on Windows: Now You're Getting Chocolatey PuppetConf2013
Rob Reynolds
 
Ad

Recently uploaded (20)

PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
PDF
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
PDF
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PPTX
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PDF
The Growing Value and Application of FME & GenAI
Safe Software
 
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
PDF
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
PPTX
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
The Growing Value and Application of FME & GenAI
Safe Software
 
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 

Automated Testing but like for PowerShell (April 2012)

  • 1. Automated Testing but like For PowerShell Rob Reynolds
  • 3. Who am I? Who cares… • Rob Reynolds • Technical Lead for VML • OSS – Chocolatey / Chuck Norris Framework / NuGet – Various contributions to other projects • ferventcoder – twitter, gmail, you name it • ferventcoder.com / Devlicio.us • Automated Testing for 8 years
  • 4. Topics d • Automated Testing… – Integration Testing – Mocking – Unit Testing • Behavior Driven Development… – What does it all mean? • ..but like for PowerShell? – Pester Entire presentation w/examples: http://bit.ly/powershellbdd
  • 6. Test Automation • Test automation is the use of software to control the execution of tests, the comparison of actual outcomes to predicted outcomes, the setting up of test preconditions, and other test control and test reporting functions.[1] Commonly, test automation involves automating a manual process already in place that uses a formalized testing process. • -Wikipedia
  • 7. So what is test automation? • Making executable tests to determine your software works appropriately
  • 8. Fallacies of automated testing • “Automated tests will prove the absence of bugs” • “’Unit’ testing is easy” • “One class – one test class” • “Testing takes little time”
  • 10. Why do automated testing? • “We never touch that piece of code. A guy wrote it a long time ago and he’s not here anymore. It just works.” – Translation “We have no idea WTF it does and have no test automation on it to help us figure it out.”
  • 11. So why do automated testing? • Maintenance – change is a constant • Feedback cycles • Scenarios / edge cases • Gives you confidence in the code – Works appropriately
  • 12. What are the types of automated tests? • White box (MSTest / Nunit / xUnit / MbUnit) – Unit – Integration • Functionality – Groups of functionality • Database Tests • Black box (FitNesse) – End 2 End – System Integration Testing • Performance testing
  • 13. What are the types of automated tests? • White box (MSTest / Nunit / xUnit / MbUnit) – Unit – Integration • Functionality – Groups of functionality • Database Tests • Black box (FitNesse) – End 2 End – System Integration Testing • Performance testing
  • 14. What are the types of automated tests? • White box – Unit – Integration • Functionality – Groups of functionality • Database Tests Why do we categorize? Is it because we are just developers and everything has a place?
  • 15. Reasons for categorization • Feedback cycles • Maintenance • “The more units put into something the greater the feedback cycle and the less maintainable the test.”
  • 16. Unit Testing • Test a “unit” of something • But WTF is a unit? – A near religion around this • For purposes of discussion a unit is one class / sometimes one method in code
  • 17. Integration Testing • Integration – Functionality – Groups of functionality – Database Tests “Anything that tests more than one unit as part of the same test is an integration”
  • 18. But wait, couldn’t that mean all tests are integration?
  • 19. Integration Testing • Integration – Functionality – Groups of functionality – Database Tests “Anything that tests more than one unit as part of the same test is an integration” Yes, most tests we write are a blend of unit and integration but we strive for unit testing
  • 20. Demo
  • 21. Where does Mocking come in?
  • 22. Where does mocking come in? • Fakes, mocks, stubs – oh my! – Dummies - objects are passed around but never used – Fake - working implementations with possible shortcuts – Stubs - provide canned answers (answer state questions) – Mocks - objects with you can set expectations and verify behavior on • Known as test doubles
  • 23. Test Doubles – is it okay to blend? • Most of us never write a true stub/fake/mock/etc but something that blends ideas from each of these
  • 25. This is not BDD… • ...but the style of writing for your tests in a natural language • BDD can be a religious battle and this talk is not about that (check out Dan North for more info) • Describe behaviors and interactions • Think not about “tests” but about behaviors and specifications
  • 26. Demo
  • 27. …but like for PowerShell
  • 28. Meet Pester • https://github.com/scottmuc/Pester • BDD style of test writing
  • 29. Demo
  • 30. But is Pester enough? • Does not get you to unit testing alone • Does no mocking/stubbing
  • 31. How to get there • A little ingenuity • Maybe a mocking/stub framework for PowerShell in the future – what would you name it? – PowerMock? – PSomething – PShellshock
  • 32. PowerShell Unit Testing • A PowerShell unit is a function • Functions can be overwritten by scoping a function of the same name
  • 33. PowerShell Stubbing • Functions can be overwritten by a function of the same name and parameters • This allows you to interrupt and stub the functionality • “I want behavior verification. I want my mock”
  • 34. PowerShell Mocking • After you have implemented the stubs you allow different behaviors to be returned through conventional properties and flags
  • 35. Demo
  • 36. Questions? • ferventcoder – twitter, gmail, etc • Pester – https://github.com/scottmuc/Pester#readme • Chocolatey – http://chocolatey.org • Mocks aren’t stubs - http://martinfowler.com/articles/mocksArentS tubs.html