Never miss a beat

Join my newsletter.

Tag: cobra

Testing a Cobra CLI in Go

Published: 7/18/2019

Go has a fantastic library for writing CLI’s (Command Line Interfaces) called Cobra . I’ve been working on a CLI named Deckard for a few months now. Being new to Go, I had (lazily) shied away from writing tests. However, after thinking about my test plan and doing a little refactoring, I’ve found a great way to handle testing your Cobra CLI application. The idea behind Cobra is that you simply write “Command” functions. These command functions are then called by the Cobra library when it…