elliotchance / tf

✔️ tf is a microframework for parameterized testing of functions and HTTP in Go.
MIT License
137 stars 3 forks source link

Can also be used with methods #4

Closed elliotchance closed 6 years ago

elliotchance commented 6 years ago

This works:

type Item struct {
    a, b float64
}

func (i Item) Sum() {
    return i.a + i.b
}

func TestItem_Average(t *testing.T) {
    Sum := tf.Function(t, Item.Sum)

    Sum(Item{4.2, 5.1}).Returns(9.3)
}

Should add this to the docs.