Skip to content

Adding support for subtests using the testify/suite library with delve #861

@edermanoel94

Description

@edermanoel94

Hey, after add the support for testify with delve, What do you think about implement support for subtests using testify/suite library with delve.

Give an example:

type ExampleSuite struct {
	suite.Suite
	value int
}

func (s *ExampleSuite) SetupTest() {
	s.value = 10
}

func (s *ExampleSuite) TestSubtraction() {
    s.Run("test with negative numbers", func() {
        result := s.value - 3
	s.Equal(7, result)
    })

   s.Run("test with positive numbers", func() {
        result := s.value - 3
	s.Equal(7, result)
    })	
}

func TestExampleSuite(t *testing.T) {
	suite.Run(t, new(ExampleSuite))
}

If i try to run TestNearest inside the subtest test with negative numbers will execute all subtests inside the Method TestSubtraction. So i try to understand this piece of code for create a new pattern:

let test#go#patterns = {
  \ 'test': [
    \ '\v^\s*func ((Test|Example).*)\(',
    \ '\v^\s*func \(.*\) ((Test).*)\(',
    \ '\v^\s*t\.Run\("(.*)"',
  \],
  \ 'namespace': [
    \ '\v^\s*func ((Test).*)\(',
    \ '\v^\s*t\.Run\("(.*)"',
  \],
\}

But it is seems a litte hard, do you have any idea how i could implement this pattern ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions