November 2018
Intermediate to advanced
346 pages
8h 12m
English
Let's examine the test for the Get endpoint in the business layer, as shown in the following code:
func TestGetter_Do(t *testing.T) { // inputs ID := 1 name := "John" // call method getter := &Getter{} person, err := getter.Do(ID) // validate expectations require.NoError(t, err) assert.Equal(t, ID, person.ID) assert.Equal(t, name, person.FullName)}
This test is almost the same as the one in the previous section. Perhaps this is logical, given that it's the same endpoint. But let's take a selfish view—what does this test give us, other than better unit test coverage, that the previous one did not?
Nothing. Because the previous test was effectively an integration test, it tested the entire stack. This test is also an integration ...
Read now
Unlock full access