Skip to content

Commit

Permalink
suite: fix TestSubtestPanic failure (#1501)
Browse files Browse the repository at this point in the history
The subtest of TestSubtestPanic is expected to fail, but that must not
make the testuite of package 'suite' to fail. So call Skip to make 'go
test' to ignore that expected failure.
  • Loading branch information
dolmen committed Nov 1, 2023
1 parent 331c520 commit 6868057
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion suite/suite_test.go
Expand Up @@ -669,9 +669,14 @@ func (s *subtestPanicSuite) TearDownSubTest() {
}

func (s *subtestPanicSuite) TestSubtestPanic() {
s.Run("subtest", func() {
ok := s.Run("subtest", func() {
panic("panic")
})
// The panic must have the test reported as failed
if s.False(ok, "TestSubtestPanic/subtest failure is expected") {
// But we still want to success here, so just skip.
s.T().Skip("Subtest failure is expected")
}
}

func TestSubtestPanic(t *testing.T) {
Expand Down

0 comments on commit 6868057

Please sign in to comment.