tf: A Microframework For Parametrized Testing of Functions in Go is a microframework for parametrized testing of functions in Go.

I wrote this because I was tired of creating a []struct{} fixture for most of my tests. I knew there had to be an easier and more reliable way.

It offers a simple and intuitive syntax for tests by wrapping the function:

import ""// Remainder returns the quotient and remainder from dividing two integers.
func Remainder(a, b int) (int, int) {
return a / b, a % b
func TestRemainder(t *testing.T) {
Remainder := tf.Function(t, Remainder)

Remainder(10, 3).Returns(3, 1)
Remainder(10, 2).Returns(5, 0)
Remainder(17, 7).Returns(2, 3)

Assertions are performed with testify. If an assertion fails it will point to the correct line so you do not need to explicitly label tests.

The above test will output (in verbose mode):

=== RUN   TestRemainder
--- PASS: TestRemainder (0.00s)
=== RUN TestRemainder/Remainder#1
--- PASS: TestRemainder/Remainder#1 (0.00s)
=== RUN TestRemainder/Remainder#2
--- PASS: TestRemainder/Remainder#2 (0.00s)
=== RUN TestRemainder/Remainder#3
--- PASS: TestRemainder/Remainder#3 (0.00s)

Originally published at on August 7, 2018.

I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store