You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, go test runs a go vet before its execution. Traditionally, unused symbols in Go are considered compilation errors. This proposal aims to equate tests with empty bodies to unused symbols, and thus, they must be removed.
Right now, a test suite that looks like this:
// ...funcTestTarget(t*testing.T) {}
// ...
will return success:
=== RUN TestTarget
--- PASS: TestTarget (0.00s)
PASS
With this proposal, instead of getting a test success, it would return a go vet error.
I cannot think of one legitimate use case for an empty test. It seems to be a human error always.
As source code analysis is necessary, it seems that cmd/vet is the more appropriate home for this change rather than cmd/build. Also, there is zero false positives in this case, as the AST that needs to be asserted is very small.
Ideally, it would target functions using *testing.T, *testing.B, *testing.F, testing.TB.
The text was updated successfully, but these errors were encountered:
In committed code, the frequency is low because empty tests are usually an artifact of building up a test suite/case. I do not have metrics in committed code to justify this proposal, except for occasional accidental commits that are soon fixed.
Currently,
go test
runs ago vet
before its execution. Traditionally, unused symbols in Go are considered compilation errors. This proposal aims to equate tests with empty bodies to unused symbols, and thus, they must be removed.Right now, a test suite that looks like this:
will return success:
With this proposal, instead of getting a test success, it would return a
go vet
error.I cannot think of one legitimate use case for an empty test. It seems to be a human error always.
As source code analysis is necessary, it seems that
cmd/vet
is the more appropriate home for this change rather thancmd/build
. Also, there is zero false positives in this case, as the AST that needs to be asserted is very small.Ideally, it would target functions using
*testing.T
,*testing.B
,*testing.F
,testing.TB
.The text was updated successfully, but these errors were encountered: