'Go test not running specific test despite flag inclusion

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 all tests work:

go-playground > go test -v ./...                         
?       go-playground   [no test files]
=== RUN   Test
OK: 0 passed
--- PASS: Test (0.00s)
PASS
ok      go-playground/test      (cached)
=== RUN   Test
start
start one
start two
OK: 2 passed
--- PASS: Test (0.00s)
PASS
ok      go-playground/test/abc  0.010s
?       go-playground/tree      [no test files]

Trying to run just the one test TestOne all failed

go-playground > go test -v -check=TestOne ./...                                                                                         INT 17:36:03
?       go-playground   [no test files]
go-playground > go test -v -check=abc ./...                                   
?       go-playground   [no test files]
go-playground > go test -v -gocheck.f=TestOne ./...                               
?       go-playground   [no test files]
go-playground > go test -v -gocheck.f TestOne ./...                                
?       go-playground   [no test files]
go-playground > go test -v -gocheck.f TestSuite ./...                               
?       go-playground   [no test files]
go-playground > go test -v -gocheck.f TestSuite ./...                               
?           go-playground   [no test files]
go-playground > go test -v -run TestOne ./test/...                                           
testing: warning: no tests to run
PASS
ok      go-playground/test      (cached) [no tests to run]
testing: warning: no tests to run
PASS
ok      go-playground/test/abc  0.004s [no tests to run]
go-playground > go test -v -run TestOne ./...                                                    
?       go-playground   [no test files]
testing: warning: no tests to run
PASS
ok      go-playground/test      (cached) [no tests to run]
testing: warning: no tests to run
PASS
ok      go-playground/test/abc  (cached) [no tests to run]
?       go-playground/tree      [no test files] 

Nothing seems to work. Mind pointing out what did I miss?



Solution 1:[1]

This is mostly a question about "gopkg.in/check.v1". As an alternative you can cd abc and use go test -v -check.f=TestOne. That will work. You should not expect go test -run TestOne to work. This is a not a test from the go command's perspective. The only test from its perspective is func Test(t *testing.T) { TestingT(t) }.

As for whether combinations of package paths and package pattern matching are allowed with "gopkg.in/check.v1", such as:

go test -v -gocheck.f=TestOne ./...

I am not sure. I suggest contacting the authors of the package http://labix.org/gocheck .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tim