November 27, 2019

249 words 2 mins read

Better bash: Unit and integration testing

Better bash: Unit and integration testing

C.J. Jameson explains how to test all the things, even your bash scripts. Using the BATS framework, it's cheap to write both high- and low-level tests to drive out more modular and readable bash scripts.

Talk Title Better bash: Unit and integration testing
Speakers C.J. Jameson (Pivotal)
Conference Velocity
Conf Tag Build resilient systems at scale
Location Santa Clara, California
Date June 21-23, 2016
URL Talk Page
Slides Talk Slides
Video

You should test your scripting languages as you do the rest of your codebase. Bash scripts are notorious for being inscrutable and brittle. Too often, they’re written with one purpose in mind and end up as snowflakes on servers. But these scripts are holding your build and deployment processes together. C.J. Jameson explains how to test all the things, even your bash scripts, by making assertions about what scripts represent with integration tests and driving out modular design with unit tests. Using the BATS framework, it’s cheap to write both high- and low-level tests to drive out more modular and readable bash scripts. BATS is a simple testing framework for bash. C.J. discusses the improvements he and his teammates made around base BATS to support both integration and unit testing, shares the basic BATS project setup, and outlines additional features, showing a bash-script refactoring that is enabled and supported by two layers of test coverage. C.J. also recommends additional tools in the bash ecosystem to keep your code robust and clean, all within a normal dev workflow experience.

comments powered by Disqus