fix minor unreachable code caused by t.Fatal by Abirdcfly · Pull Request #3574 · hyperledger/fabric
Type of change
- Test update
Description
t.Fatal or os.Exit will make the subsequent code unreachable.
https://pkg.go.dev/testing#T.Fatalf
Fatalf is equivalent to Logf followed by FailNow.
Additional details
see https://go.dev/play/p/I6MX-QOTC9n for t.Fatal example:
package main import ( "testing" ) func TestLastIndex(t *testing.T) { t.Errorf("first line") t.Errorf("second line") t.Fatalf("t.Fatalf will cause exit") t.Fatalf("so this line cant reach") } /* output: === RUN TestLastIndex prog.go:8: first line prog.go:9: second line prog.go:10: t.Fatalf will cause exit --- FAIL: TestLastIndex (0.00s) FAIL Program exited. */