Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

Table-driven tests

Table-driven tests are a quite compact and rather terse way to efficiently test the behavior of a particular piece of code in a host of different scenarios. The format of a typical table-driven test consists of two distinct parts: the test case definitions and the test-runner code.

To demonstrate this, let's examine a possible implementation of the infamous FizzBuzz test: given a number, N, the FizzBuzz implementation is expected to return Fizz if the number is evenly divisible by 3, Buzz if the number is evenly divisible by 5, FizzBuzz if the number is evenly divisible by both 3 and 5, or the number itself in all other cases. Here is a listing from the Chapter04/table-driven/fizzbuzz.go file, which contains the implementation ...

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.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content