-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
testing: Short() does not work in TestMain() #9825
Comments
TestMain is executed before flag.Parse in (*testing.M).Run. I think this is intentional, because it provides a way to modify the In conclusion, I think a docs clarification is needed, it's not a bug. |
Please include that testing.Verbose() also doesn't work in TestMain. Came here to post an issue about it, but now I see it's by design. |
I really would like to see changed as well. func TestMain(m *testing.M) {
// Reset test db before running test.
// The schema is only imported once for all test
if !testing.Short() {
fmt.Println("Initializing test DB for integration test (disable with `go test -short`)")
initTestDB()
}
os.Exit(m.Run())
} And initTestDB() is always run :( |
I don't think this is going to change. If you want to use testing.Verbose or testing.Short, call flag.Parse in |
Ok, thanks for the info |
I've sent https://golang.org/cl/7604 to add the docs.
|
👍 👍 |
The
testing.Short()
have to report-test.short
flag is set. But, it looks not working onTestMain(*testing.M)
.You can see this behavior on this example.
https://gist.github.com/umisama/cebb1c8f9022e5402d21
Here is output on my environment.
In the example I expected to
testing.Short()
returns true forTestXxx()
includingTestMain(*testing.M)
, but it returns false onTestMain(*testing.M)
.I'll create patch if this behavior is unexpected.
The text was updated successfully, but these errors were encountered: