The Startup
Published in

The Startup

Unit Testing CLI Programs in Go

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:

--

--

--

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +756K followers.

Recommended from Medium

Blog | Choosing the Right Bitrate for Your OBS Live Stream

TIL 0605 Team Project ESC

Blog | FFMPEG for Beginners: Scripts for Processing, Converting, and Streaming Video

Getting Started with Arrays in Ruby

Algorithms: Searching an Unbalanced Tree

Big Data: Overview of apache Hadoop

Dichotomy — Monolithic Vs Microservices

Explore the possibilities with hundreds of domain extensions — {link} -

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Elliot Chance

Elliot Chance

I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓 elliotchance@gmail.com

More from Medium

A Do-it-yourself Implementation of the Golang Middleware

Go Context for a layman

Generics in Golang.

How to Achieve 100% Code Coverage in Golang Unit Test?