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 ...
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