
Go: Using Subtests and Sub-Benchmarks - pieterr
https://blog.golang.org/subtests
======
willalexander
One detail not mentioned in this post is the fact that T.Run returns whether
the subtest succeeded. This is necessary if you have subtests that rely on the
results of previous subtests, because a call to t.Fatal or t.FailNow in the
subtest will not terminate the outer test early. The boolean allows the outer
test to terminate early if necessary:

    
    
      var foo Foo
      if !t.Run("Foo", func(t *testing.T) {
              f, err := NewFoo()
              if err != nil {
                      t.Fatal(err)
              }
              foo = f
      }) {
              return
      }
      t.Run("Bar", func(t *testing.T) {
              err := Bar(foo)
              // ... 
      })

