在以下環(huán)境中:code$ pwd/home/user1/codecode$ echo $GOPATH/home/user1/golib:/home/user1/codecode$ lsbin pkg src code$ ls src/github.com/myhub/codingtest/main.go test_main.gocode$ code$ code$ code$ code$ code$ cat src/github.com/myhub/codingtest/test_main.go package mainimport "testing"func TestSplit(t *testing.T) { gotAllButLast, gotLast := split(2013) wantAllButLast := 201 wantLast := 3 if gotAllButLast != wantAllButLast { t.Errorf("got %d but expected %d", gotAllButLast, wantAllButLast) } if wantLast != gotLast { t.Errorf("got %d but expected %d", gotLast, wantLast) }}code$ code$ code$ code$ code$ code$ cat src/github.com/myhub/codingtest/main.go package main// Spit n into all but its last digit and its last digitfunc split(n int) (int, int) { return n / 10, n % 10}func main() {}code$ go test給出以下錯(cuò)誤:code$ go test github.com/myhub/codingtest? github.com/myhub/codingtest [no test files]code$ code$ code$ code$ code$ code$ 如何解決no test files error?
1 回答

當(dāng)年話(huà)下
TA貢獻(xiàn)1890條經(jīng)驗(yàn) 獲得超9個(gè)贊
要解決您的錯(cuò)誤,您需要將 test_main.go 重命名為 main_test.go
正如您在文檔中看到的
要編寫(xiě)新的測(cè)試套件,請(qǐng)創(chuàng)建一個(gè)名稱(chēng)以 _test.go 結(jié)尾的文件
- 1 回答
- 0 關(guān)注
- 174 瀏覽
添加回答
舉報(bào)
0/150
提交
取消