Refactor to use a subtest

This commit is contained in:
Oliver Davies 2022-01-26 18:00:00 +00:00
parent a857ef5957
commit 4c1fb0ec5a

View file

@ -3,10 +3,12 @@ package main
import "testing"
func TestHello(t *testing.T) {
got := Hello("Oliver")
want := "Hello, Oliver"
t.Run("saying hello to people", func (t *testing.T) {
got := Hello("Oliver")
want := "Hello, Oliver"
if got != want {
t.Errorf("got %q want %q", got, want)
}
if got != want {
t.Errorf("got %q want %q", got, want)
}
})
}