November 2018
Intermediate to advanced
346 pages
8h 12m
English
I wish I had a clear, quantifiable metric to give you as to what you should and should not test, but it's just not that clear. The first rule is definitely as follows:
This includes language features, such as those shown in the following code:
func NewPet(name string) *Pet { return &Pet{ Name: name, }}func TestLanguageFeatures(t *testing.T) { petFish := NewPet("Goldie") assert.IsType(t, &Pet{}, petFish)}
This also includes simple functions, as shown in the following code:
func concat(a, b string) string { return a + b}func TestTooSimple(t *testing.T) { a := "Hello " b := "World" expected := "Hello World" assert.Equal(t, expected, concat(a, b))}
After that, be pragmatic. We get ...
Read now
Unlock full access