How to disable test caching in Go and force rerun tests?
Hi everyone! I started learning Go and writing tests for my project. I noticed strange behavior: when I run tests multiple times in a row using `go test`, after the first run they start executing instantly, even if I changed the source code or tests. In the output I see `(cached)`, and this confuses me.\n\nExample: I have a simple test:\n\n```go\npackage main\n\nimport "testing"\n\nfunc TestAddition(t *testing.T) {\n result := 2 + 2\n if result != 5 { // intentionally made an error\n t.Errorf("2 + 2 = %d, want 5", result)\n }\n}\n```\n\nI run it the first time — the test fails as expected. I fix `5` to `4`, run again — but the test still shows the old result with an error! Only after `go clean -testcache` or explicitly adding the `-count=1` flag does the test run
No answers yet.
Log in to leave an answer