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

Cannot longer run unit-tests using check from vscode due to invalid stretchr/testify detection. #1911

Closed
alex-kovoy opened this issue Sep 4, 2018 · 7 comments

Comments

@alex-kovoy
Copy link

alex-kovoy commented Sep 4, 2018

This PR #1707 introduced a breaking change. Now it's no longer possible to run unit-tests from vscode if your tests have similar to 'stretchr/testify' suite.Run() call in them

For example, when using gopkg.in/check.v1 package you may have the following test suite

import (
        ...
	check "gopkg.in/check.v1"
)

type LicenseSuite struct {	
}

var _ = check.Suite(&LicenseSuite{})

func (s *LicenseSuite) TestLicenseLegacy(c *check.C) {
  ...
}

which vscode would try to run with stretchr/testify flags assuming that this library is used (based on regex parsing).

I suggest to remove a support for 3d party libraries from a default behavior.

@ramya-rao-a
Copy link
Contributor

Thanks for reporting this @alex-kovoy

I'll look into fixing this soon. I just needed to understand one detail about the check package.
Is there a way to run the individual tests in a suite when using the check package?

@ramya-rao-a ramya-rao-a changed the title Cannot longer run unit-tests from vscode due to invalid stretchr/testify detection. Cannot longer run unit-tests using check from vscode due to invalid stretchr/testify detection. Sep 10, 2018
@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Sep 10, 2018

I tried using go test -check.f but I keep getting flag provided but not defined: -check. Am I missing something?

@ramya-rao-a
Copy link
Contributor

Also, how have you been trying to run the tests? Using the commands to run tests in package/file/cursor or code lens to run tests in package/file/function?

@alex-kovoy
Copy link
Author

alex-kovoy commented Sep 10, 2018

When from vscode, I run the tests in package/file by triggering vscode command: F1 -> Go: test file. Upon executing this command, the extension would run the golang tests with stretchr/testify flags instead of using default golang flags for running the tests in the file.

I tried using go test -check.f but I keep getting flag provided but not defined: -check. Am I missing something?

You can do it with go test -check.f=TestMyFunction . Here is more info

@ramya-rao-a
Copy link
Contributor

Thanks @alex-kovoy

I have pushed a fix to the master branch. Can you follow the instructions to download and install the beta version of this extension to test it out?

@ramya-rao-a
Copy link
Contributor

I've also logged #1921 to support running such tests individually

@ramya-rao-a
Copy link
Contributor

The fix for this is now out in the latest update to this extension (0.6.90)

@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants