Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check.f not working #130

Open
MeCode4Food opened this issue Aug 24, 2021 · 3 comments
Open

check.f not working #130

MeCode4Food opened this issue Aug 24, 2021 · 3 comments

Comments

@MeCode4Food
Copy link

MeCode4Food commented Aug 24, 2021

Folder structure:

./test
├── abc
│   └── abc_test.go
└── run_test.go

run_test.go

package test

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

	"testing"
)

func Test(t *testing.T) {
	TestingT(t)
}

abc_test.go

package abc

import (
	"fmt"

	. "gopkg.in/check.v1"
)

type TestSuite struct{}

var _ = Suite(&TestSuite{})

func Test(t *testing.T) {
	TestingT(t)
}

func (s *TestSuite) SetUpSuite(c *C) {
	fmt.Println("start")
}

func (s *TestSuite) TestOne(c *C) {
	fmt.Println("start one")
}

func (s *TestSuite) TestTwo(c *C) {
	fmt.Println("start two")
}

Running go test -v ./test/... works.

Output:

OK: 0 passed
--- PASS: Test (0.00s)
PASS
ok      go-playground/test      0.003s
=== RUN   Test
start
start one
start two
OK: 2 passed
--- PASS: Test (0.00s)
PASS

Running go test -v -check.f TestSuite ./test/... does not work: I get a [no test files] output

@andyone
Copy link

andyone commented Sep 1, 2021

You can't use any of custom flags (-check.*) outside the tests directory (all flags handled by the test suite itself), so you can't use syntax like ./... with custom flags.

You can use custom flags only when you are running tests in the current directory.

@sdhoward
Copy link

sdhoward commented Apr 7, 2022

is this a golang limitation or a check limitation?

@jhenstridge
Copy link
Contributor

The -check.* flags are interpreted by the test executable that is built. So they can't be interpreted before selecting which packages to test.

Instead, you can run:

go test -v ./test/... -check.f TestSuite

This will cause go test to pass the arguments after the package name through to the test executable(s) as is. Note that if some of the selected packages aren't using go-check, then they will likely fail due to the unknown command line argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants