Testing with Table-Driven Testing
When you’re writing tests for your command-line tool, you often want to write test cases that cover different variations of the function or tool usage. By doing this, you ensure that the different parts of your code are working, increasing the reliability of your tests and tool. For example, to test the filterOut function from the walk tool, it’s a good idea to define test cases for the different conditions such as filtering with or without extension, matching or not, and minimum size.
One of the benefits of Go is that you can use Go itself to write test cases. You don’t need a different language or external frameworks. By leveraging Go, you use all the language’s features to help define your test cases. A ...
Get Powerful Command-Line Applications in Go now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.