On Friday, March 29, 2019 at 2:20:53 AM UTC+1, twp...@gmail.com wrote:
>
> I have a bunch of integration tests which depend on external services. 
> I've added the build tag "integration" for each source file containing such 
> tests so they are only run when I do:
>   $ go test -tags=integration ./...
>
> Go 1.12, by default, caches the tests results, which is exactly what I 
> don't want because these "external services" are usually different backends 
> running on my local machine. When I'm developing code, I want to test my 
> code against the current backend running on my local machine, and not have 
> "go test" return the result from running the tests against the previous 
> backend.
>
> I can disable caching by passing the "-count=1" argument to "go test" but 
> this is a pretty blunt instrument: I need to remember when I'm running an 
> integration test and when I'm not, and it applies to the whole set of tests 
> that I'm running.
>
> Ideally I'd like to specify within each test whether the result can be 
> cached or not. I looked at the documentation for testing 
> <https://godoc.org/testing>, but the word "cache" is not present,
>
> Is there any way for Go test code to control whether its results should be 
> cached?
>

No, and I doubt such an API will be added.

>From `go help cache` and `go help test` it seems that there is no control 
variable to disable test caching.
There is only a control variable for debugging: `GODEBUG=gocachetest=1`.

However, since all your integration tests have an `integration` build tag 
and you need to run them with `-tags=integration`, I'm not sure to 
understand why you say that "I need to remember when I'm running an 
integration test and when I'm not".
You just need to specify `-count=1` every time you specify 
`-tags=integration`.


Regards
Manlio

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to