More golang testing tips

This commit is contained in:
Wilfried OLLIVIER 2019-05-02 21:18:51 +02:00
parent 6ea7b84b36
commit 0fdf28c615

View file

@ -77,3 +77,25 @@ t.Fatalf()
## I don't want my tests to be messy (kudos @athoune) ## I don't want my tests to be messy (kudos @athoune)
[Assert](https://godoc.org/github.com/stretchr/testify/assert) [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
```