Unit Testing CLI Programs in Go

Elliot Chance
Feb 29, 2020 · 2 min read
Photo by John Schnobrich on Unsplash

It’s a common scenario — for me at least — to be building a CLI tool (main package) that has CLI options (flags package) that I want to add unit tests to.

Here’s a simple example of a CLI tool that adds or multiplies some input numbers: