Skip to content

suite: Skipping a test in BeforeTest prevents test execution but not AfterTest #1781

@brackendawson

Description

@brackendawson

Description

Related to #473 and #1722. If testing.T.Skip is called in Before test, we should skip that test and its teardowns. If it's called in the suite setup, we should skip the entire suite.

Step To Reproduce

package kata_test

import (
	"testing"

	"github.com/stretchr/testify/suite"
)

type My struct {
	suite.Suite
}

func (m *My) BeforeTest(s, t string) {
	m.T().Skip()
	panic("before")
}

func (m *My) AfterTest(s, t string) {
	panic("after")
}

func (m *My) TestA() {
	panic("during")
}

func TestIfy(t *testing.T) {
	suite.Run(t, &My{})
}

Expected behavior

No panics

Actual behavior

panic: "after"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions