# Table driven tests in Go

DevFeed: [Table driven tests in Go](<https://devfeed.tech/articles/table-driven-tests-in-go-22198.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2023/01/table-driven-tests-in-go.html>)

Published: 2023-01-19T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [test](<https://devfeed.tech/topics/test.md>)

Tags: [documentation](<https://devfeed.tech/tags/documentation.md>), [go](<https://devfeed.tech/tags/go.md>), [go-test](<https://devfeed.tech/tags/go-test.md>), [golang](<https://devfeed.tech/tags/golang.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [learn](<https://devfeed.tech/tags/learn.md>), [table-driven-tests](<https://devfeed.tech/tags/table-driven-tests.md>), [tests](<https://devfeed.tech/tags/tests.md>), [tips](<https://devfeed.tech/tags/tips.md>), [unit-tests](<https://devfeed.tech/tags/unit-tests.md>), [video](<https://devfeed.tech/tags/video.md>)

## AI overview

A video tutorial explains table-driven tests in Go and shows how sub-tests can make failing cases easier to identify when testing many inputs.

## Source excerpt

Introduction Table tests are a great way to test different inputs and associated outputs for a function in Go. To write a table test, you define a slice of some data struct with fields of the input data you'll need and the expected outcome. Then you can loop through this slice and pass the data stored for each element to your function. One disadvantage of table tests is as the data set in your slice grows, the harder it is to find the failing case. Luckily, Miki will share some tips to manage this with the Go test suite.