Training: June 20–21, 2016
Tutorials: June 21, 2016
Keynotes & Sessions: June 22–23, 2016
Santa Clara, CA

Better bash: Unit and integration testing

C.J. Jameson (Pivotal)
3:40pm–4:20pm Wednesday, 06/22/2016
DevOps, First time at Velocity Santa Clara
Location: Mission City Ballroom B1-3 Level: Intermediate

Prerequisite knowledge

Attendees should have basic experience with bash scripting. If you've tried to look into your codebase's build scripts but not gotten anywhere because they're unintelligible, that's great. It's also great if you're a more seasoned scripter.

Description

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.

Photo of C.J. Jameson

C.J. Jameson

Pivotal

C.J. Jameson is a software engineer with Pivotal Labs. He has worked internally across Pivotal’s Cloud Foundry and big data platforms.