Skip to content

cmd/go: how to disable (run test) Cached #24573

Closed
@imkos

Description

@imkos

What version of Go are you using (go version)?

1.10 (win10_x64)

go test, The results always appear cached.
I made an HTTP request, the result of the server return was changed, but the test results were old.
However, run test (cached) does not make HTTP requests
Unless, I modified the code in func Test_** (), the result is the latest

func Test_gotest_cached(t *testing.T) {
	req := NewRequest()
	resp, b_resp, e1 := req.Get("http://10.20.60.52:8080/help")
	if e1 != nil {
		t.Error(e1)
		return
	}
	fmt.Println(string(b_resp), resp.Status)
}

server code:

http.HandleFunc("/help", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("hello!"))
	})

go test -v -timeout 30s newpay_svc -run ^Test_gotest_cached$

"hello!" => "hello world!" , but the test results were old.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions