github.com/elliotchance/tf 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 "github.com/elliotchance/tf" // 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):