3 ms·
Use table driven tests. func TestFoo(t *testing.T) { list := []struct { want string input string expectedErr error }{ {item1}, {item2},
by kardianos 5y ago
Use table driven tests.
func TestFoo(t *testing.T) {
list := []struct {
want string
input string
expectedErr error
}{
{item1},
{item2},
}
runtest
- troutwine 5y agoThat’s not property testing. Yes there is a property being checked but you the user are selecting the inputs by hand which lumps in whatever biases you might bring to the test. Property testing is a property to validate, randomized search over the input space and, ideally, shrinking of inputs that fail the property. The benefit is you get to search over more of the input space that a human would normally do with an explicit table of inputs and with hopefully less bias toward inputs that don’t fail the property.