Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Testify suite tests not running #1968

Closed
@MathiasGr

Description

Starting from at least 0.6.90, tests bound to testify suites aren't detected by the vscode-go extension. Thus neither codelens or the "Test function at cursor" work anymore for this kind of test.

I also found a second issue while debugging the extension, which drove me crazy because it made the example suite from the testify github page work and show codelenses. The testFuncRegex is missing a ^ in front of Example, which makes the extension treat (suite *ExampleTestSuite) TestExample() like a regular test function, because it includes Example

Last, it should be documented somewhere that even with the fix in #1969 , users need to include "go.gotoSymbol.includeImports": true in their settings for testify to be properly detected.

Steps to Reproduce:

  • Open vscode with the extension enabled and create a test file with the code below
  • Try looking for codelenses and try "Test function at cursor"
package example

import (
	"testing"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/suite"
)

type Suite struct {
	suite.Suite
	VariableThatShouldStartAtFive int
}

func (suite *Suite) TestExample() {
	assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive)
}

func TestSuite(t *testing.T) {
	suite.Run(t, new(Suite))
}

Edit: fix for both issues in #1969

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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