SlideShare a Scribd company logo
@cjcjameson1
Unit and Integration Testing
C.J. Jameson
Better Bash
@cjcjameson
I work at Pivotal, I’m a Toolsmith, I tweet some
2
@cjcjameson3
Customer = Engineer
Reliability & predictable outcomes
Good bug reports
Eager to make tradeoffs
@cjcjameson4
Tradeoffs?
Customization vs. Reuse
User experience vs. Exposing internals
YAGNI
@cjcjameson
How good does this need to be?
The tradeoff with your Bash scripts
5
effort
time
¯_(ツ)_/¯
...sorry dude
@cjcjameson6
Here’s my shiny tool…?
@cjcjameson
cover this square with an image (540 x 480 pixels)
7
STOP
When would
anyone write a
test themselves?
@cjcjameson
cover this square with an image (540 x 480 pixels)
8
STOP
When would
anyone write a
test themselves?
@cjcjameson
cover this square with an image (540 x 480 pixels)
9
STOP
When would
anyone run
the tests?
@cjcjameson10
When would anyone run the tests?
STOP
@cjcjameson11
When would anyone run the tests?
P
https://github.com/koalaman/shellcheck
@cjcjameson12
1
https://en.wikipedia.org/wiki/Unit_testing
In general, unit tests...1
Find problems early Make change easy
Drive modular designAre documentationMake integration easy
@cjcjameson13
You’re writing an installer file
Be documentation
Make integration easy
(esp. across distros)
So your unit tests should help:
@cjcjameson14
You’re touching this code for the first and only time
Drive modular designMake change easy
So your unit tests should help:
Be documentation
@cjcjameson15
You’re treating the filesystem as a first-class object
Drive modular designFind problems early
So your unit tests should help:
@cjcjameson16
You’re writing a shared `common.bash` library
Be documentationMake integration easy
So your unit tests should help:
@cjcjameson17
You’re crafting a CLI user experience
Make change easyFind problems early
So your unit tests should help:
@cjcjameson18
Example: ruby-build
@cjcjameson19
Example: Concourse’s `git-resource`
https://ci.concourse.ci/pipelines/resources/jobs/git-resource
@cjcjameson20
Example: “Check the executable bit”
@cjcjameson21
Example: “Check the executable bit”
@cjcjameson22
Example: “Check the executable bit” - integration
@cjcjameson23
Inside the BATS `run` command
https://github.com/sstephenson/bats
- Exit codes are swallowed
- `stdout` and `stderr` are swallowed
- Start by `source`ing in the file under test … so the file runs
@cjcjameson24
Thanks!

More Related Content

Viewers also liked

State of the Internet Operating System: Web2 expo10
State of the Internet Operating System: Web2 expo10State of the Internet Operating System: Web2 expo10
State of the Internet Operating System: Web2 expo10
Tim O'Reilly
 
webfonts & @font-face :: in brief
webfonts & @font-face :: in briefwebfonts & @font-face :: in brief
webfonts & @font-face :: in brief
Paul Irish
 
Where in the publishing world are libraries?
Where in the publishing world are libraries?Where in the publishing world are libraries?
Where in the publishing world are libraries?
Katie Dunneback
 
Where 2.0 Perch Product Launch Presentation
Where 2.0 Perch Product Launch PresentationWhere 2.0 Perch Product Launch Presentation
Where 2.0 Perch Product Launch Presentation
perryevans
 
Epub in the wild
Epub in the wildEpub in the wild
Epub in the wild
liz_castro
 
Strata Conference 2014 NYC with Twitter
Strata Conference 2014 NYC with TwitterStrata Conference 2014 NYC with Twitter
Strata Conference 2014 NYC with Twitter
Taewook Eom
 
Using WordPress for Digital Workflows and More
Using WordPress for Digital Workflows and MoreUsing WordPress for Digital Workflows and More
Using WordPress for Digital Workflows and More
Kirk Biglione
 
jQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and ProfitjQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and Profit
Daniel Cousineau
 
(Short version) Building a Mobile, Social, Location-Based Game in 5 Weeks
(Short version) Building a Mobile, Social, Location-Based Game in 5 Weeks(Short version) Building a Mobile, Social, Location-Based Game in 5 Weeks
(Short version) Building a Mobile, Social, Location-Based Game in 5 Weeks
Jennie Lees
 
Kobo: What Do eBook Customers Really, Really Want? (Tools of Change 2011)
Kobo: What Do eBook Customers Really, Really Want? (Tools of Change 2011)Kobo: What Do eBook Customers Really, Really Want? (Tools of Change 2011)
Kobo: What Do eBook Customers Really, Really Want? (Tools of Change 2011)
MTamblyn
 
Smaller, Flatter, Smarter
Smaller, Flatter, SmarterSmaller, Flatter, Smarter
Smaller, Flatter, SmarterWeb 2.0 Expo
 
Social Gold: The Design of FarmVille and Other Social Games (Web2Expo 2010)
Social Gold: The Design of FarmVille and Other Social Games (Web2Expo 2010)Social Gold: The Design of FarmVille and Other Social Games (Web2Expo 2010)
Social Gold: The Design of FarmVille and Other Social Games (Web2Expo 2010)
Amitt Mahajan
 
Mobilising the world's Natural History - Open Data + Citizen Science
Mobilising the world's Natural History - Open Data + Citizen ScienceMobilising the world's Natural History - Open Data + Citizen Science
Mobilising the world's Natural History - Open Data + Citizen Science
Margaret Gold
 
Web 2.0 Expo Speech: Open Leadership
Web 2.0 Expo Speech: Open LeadershipWeb 2.0 Expo Speech: Open Leadership
Web 2.0 Expo Speech: Open Leadership
Charlene Li
 
Data Science and Smart Systems: Creating the Digital Brain
Data Science and Smart Systems: Creating the Digital Brain Data Science and Smart Systems: Creating the Digital Brain
Data Science and Smart Systems: Creating the Digital Brain
VMware Tanzu
 
Hadoop's Impact on the Future of Data Management | Amr Awadallah
Hadoop's Impact on the Future of Data Management | Amr AwadallahHadoop's Impact on the Future of Data Management | Amr Awadallah
Hadoop's Impact on the Future of Data Management | Amr Awadallah
Cloudera, Inc.
 
Tyranny of the SLA
Tyranny of the SLATyranny of the SLA
Tyranny of the SLA
J. Paul Reed
 
Locked Out in London (and tweeting about it) - version with my notes
Locked Out in London (and tweeting about it) - version with my notesLocked Out in London (and tweeting about it) - version with my notes
Locked Out in London (and tweeting about it) - version with my notes
Sylvain Carle
 
Did Social Media Hijack My Communications Strategy
Did Social Media Hijack My Communications StrategyDid Social Media Hijack My Communications Strategy
Did Social Media Hijack My Communications Strategy
Mike Smith
 
Primum non nocere - Ethical Obligations in Internet Operations
Primum non nocere - Ethical Obligations in Internet OperationsPrimum non nocere - Ethical Obligations in Internet Operations
Primum non nocere - Ethical Obligations in Internet Operations
Jan Schaumann
 

Viewers also liked (20)

State of the Internet Operating System: Web2 expo10
State of the Internet Operating System: Web2 expo10State of the Internet Operating System: Web2 expo10
State of the Internet Operating System: Web2 expo10
 
webfonts & @font-face :: in brief
webfonts & @font-face :: in briefwebfonts & @font-face :: in brief
webfonts & @font-face :: in brief
 
Where in the publishing world are libraries?
Where in the publishing world are libraries?Where in the publishing world are libraries?
Where in the publishing world are libraries?
 
Where 2.0 Perch Product Launch Presentation
Where 2.0 Perch Product Launch PresentationWhere 2.0 Perch Product Launch Presentation
Where 2.0 Perch Product Launch Presentation
 
Epub in the wild
Epub in the wildEpub in the wild
Epub in the wild
 
Strata Conference 2014 NYC with Twitter
Strata Conference 2014 NYC with TwitterStrata Conference 2014 NYC with Twitter
Strata Conference 2014 NYC with Twitter
 
Using WordPress for Digital Workflows and More
Using WordPress for Digital Workflows and MoreUsing WordPress for Digital Workflows and More
Using WordPress for Digital Workflows and More
 
jQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and ProfitjQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and Profit
 
(Short version) Building a Mobile, Social, Location-Based Game in 5 Weeks
(Short version) Building a Mobile, Social, Location-Based Game in 5 Weeks(Short version) Building a Mobile, Social, Location-Based Game in 5 Weeks
(Short version) Building a Mobile, Social, Location-Based Game in 5 Weeks
 
Kobo: What Do eBook Customers Really, Really Want? (Tools of Change 2011)
Kobo: What Do eBook Customers Really, Really Want? (Tools of Change 2011)Kobo: What Do eBook Customers Really, Really Want? (Tools of Change 2011)
Kobo: What Do eBook Customers Really, Really Want? (Tools of Change 2011)
 
Smaller, Flatter, Smarter
Smaller, Flatter, SmarterSmaller, Flatter, Smarter
Smaller, Flatter, Smarter
 
Social Gold: The Design of FarmVille and Other Social Games (Web2Expo 2010)
Social Gold: The Design of FarmVille and Other Social Games (Web2Expo 2010)Social Gold: The Design of FarmVille and Other Social Games (Web2Expo 2010)
Social Gold: The Design of FarmVille and Other Social Games (Web2Expo 2010)
 
Mobilising the world's Natural History - Open Data + Citizen Science
Mobilising the world's Natural History - Open Data + Citizen ScienceMobilising the world's Natural History - Open Data + Citizen Science
Mobilising the world's Natural History - Open Data + Citizen Science
 
Web 2.0 Expo Speech: Open Leadership
Web 2.0 Expo Speech: Open LeadershipWeb 2.0 Expo Speech: Open Leadership
Web 2.0 Expo Speech: Open Leadership
 
Data Science and Smart Systems: Creating the Digital Brain
Data Science and Smart Systems: Creating the Digital Brain Data Science and Smart Systems: Creating the Digital Brain
Data Science and Smart Systems: Creating the Digital Brain
 
Hadoop's Impact on the Future of Data Management | Amr Awadallah
Hadoop's Impact on the Future of Data Management | Amr AwadallahHadoop's Impact on the Future of Data Management | Amr Awadallah
Hadoop's Impact on the Future of Data Management | Amr Awadallah
 
Tyranny of the SLA
Tyranny of the SLATyranny of the SLA
Tyranny of the SLA
 
Locked Out in London (and tweeting about it) - version with my notes
Locked Out in London (and tweeting about it) - version with my notesLocked Out in London (and tweeting about it) - version with my notes
Locked Out in London (and tweeting about it) - version with my notes
 
Did Social Media Hijack My Communications Strategy
Did Social Media Hijack My Communications StrategyDid Social Media Hijack My Communications Strategy
Did Social Media Hijack My Communications Strategy
 
Primum non nocere - Ethical Obligations in Internet Operations
Primum non nocere - Ethical Obligations in Internet OperationsPrimum non nocere - Ethical Obligations in Internet Operations
Primum non nocere - Ethical Obligations in Internet Operations
 

Recently uploaded

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 

Recently uploaded (20)

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 

Better Bash - Unit and Integration Testing