More golang testing tips

This commit is contained in:
Wilfried OLLIVIER 2019-05-02 21:18:51 +02:00
parent 6ea7b84b36
commit 0fdf28c615
1 changed files with 22 additions and 0 deletions

View File

@ -77,3 +77,25 @@ t.Fatalf()
## I don't want my tests to be messy (kudos @athoune)
[Assert](https://godoc.org/github.com/stretchr/testify/assert)
## Shit, i want to disable my oauth test on my CI
```golang
if os.Getenv("DRONE") == "true" {
t.Skip("Skipping test in CI environment")
}
```
## Short mode
This test is too long ? Skip it !
```golang
if testing.Short() {
t.Skip("Skipping test in short mode")
}
```
```shell
go test github.com/go/pkg/package --short
```