Testing the Initial CLI Implementation
You can use different approaches to test your CLI tool. Since we already executed unit tests when developing the to-do API, we don’t need to repeat them here. Our CLI implementation is a wrapper around the API. Let’s leverage some of Go’s features and write integration tests instead. This way we’re testing the user interface of the tool instead of the business logic again.
One of the main benefits of Go is that it provides tools for automating the execution of tests out of the box; no additional frameworks or libraries are required. Since you write tests using Go itself, you can use any resources and features available with the language to write your test cases. In this case we will use the os/exec package, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access