diff options
author | Jay Zhuang <jayzhuang@google.com> | 2020-07-27 06:37:11 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-07-27 06:39:06 -0700 |
commit | cf7141fb43d9b6757c6838baa71e2edfee339d44 (patch) | |
tree | b77879f6310231831ebb7d37f07bfea1d1d59b0b /pkg/state | |
parent | 2ecf66903ed3da46fa021feeeeccad81cd82eaa6 (diff) |
Ask for *testing.T instead of storing it
Storing *testing.T on test helper structs is problematic when
subtests are used, because it is possible for nested tests to call
Fatal on parent test, which incorrect terminates the parent test.
For example
func TestOuter(t *testing.T) {
dut := NewDUT(t)
t.Run("first test", func(t *testing.T) {
dut.FallibleCall()
})
t.Run("second test", func(t *testing.T) {
dut.FallibleCall()
}
}
In the example above, assuming `FallibleCall` calls `t.Fatal` on the
`t` it holds, if `dut.FallibleCall` fails in "first test", it will
call `Fatal` on the parent `t`, quitting `TestOuter`. This is not a
behavior we want.
PiperOrigin-RevId: 323350241
Diffstat (limited to 'pkg/state')
0 files changed, 0 insertions, 0 deletions