Unit test fails with go test ./... but passes alone

I have a method X making use of crypto/rand. Several unit tests use X.

One of these tests succeeds when running alone, but fails when running all tests in that file (with go test -p 1 ./... -v).

Even strange, all tests succeeds if this one is on top of the file. It will fail only when another test who calls X gets executed first.

Why is this ? Can anyone give more details about what go test ./... does in terms of resources, optimizations, inlining, etc ?

Hi, @telo_tade. How does the test fail? Is there an error? What makes you suspect that the issue is related to crypto/rand and not due to something else? Can you show the source code for that test?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.