Golang testing: “no test files”
问题描述
Golang Test Case not Work
解决方案
Files containing tests should be called name_test
, with the _test
suffix. They should be alongside the code that they are testing.
To run the tests recursively call go test -v ./...
From How to Write Go Code:
You write a test by creating a file with a name ending in
_test.go
that contains functions namedTestXXX
with signaturefunc (t *testing.T)
. The test framework runs each such function; if the function calls a failure function such ast.Error
ort.Fail
, the test is considered to have failed.
via: https://stackoverflow.com/questions/28240489/golang-testing-no-test-files/28240537
评论