2024-08-26 12:46:47 +02:00
|
|
|
## Tests
|
|
|
|
|
2025-02-20 23:54:13 +01:00
|
|
|
Basic test run:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
go test ./... -v
|
|
|
|
```
|
|
|
|
|
|
|
|
Prettier output using `gotestsum`:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
go run gotest.tools/gotestsum@latest
|
|
|
|
```
|
|
|
|
|
|
|
|
## Coverage
|
|
|
|
|
|
|
|
Generate a coverage profile:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
go test -coverpkg=./... -coverprofile=cover.out ./...
|
|
|
|
```
|
|
|
|
|
|
|
|
View the data:
|
|
|
|
|
2024-08-26 12:46:47 +02:00
|
|
|
```shell
|
2025-02-20 23:54:13 +01:00
|
|
|
go tool cover -func cover.out
|
|
|
|
go tool cover -html cover.out
|
2024-08-26 12:46:47 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Benchmarks
|
|
|
|
|
2025-02-20 23:54:13 +01:00
|
|
|
Run all benchmarks:
|
|
|
|
|
2024-08-26 12:46:47 +02:00
|
|
|
```shell
|
|
|
|
go test ./tests -run='^$' -bench=. -benchmem
|
2025-02-20 23:54:13 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Examples only:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
go test ./tests -run='^$' -bench=Examples/ -benchmem
|
|
|
|
```
|
|
|
|
|
|
|
|
## Profiling
|
|
|
|
|
|
|
|
Generate a profile:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
go test ./tests -run='^$' -bench=Examples/ -benchmem -cpuprofile cpu.out -memprofile mem.out
|
|
|
|
```
|
|
|
|
|
|
|
|
View the data:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
go tool pprof --nodefraction=0.1 -http=:8080 ./cpu.out
|
|
|
|
go tool pprof --nodefraction=0.1 -http=:8080 ./mem.out
|
2024-08-26 12:46:47 +02:00
|
|
|
```
|