Add Go testing commands

This commit is contained in:
James Skemp 2023-06-26 13:10:59 -05:00
parent d0b028f1c7
commit f129ac43e8
1 changed files with 16 additions and 0 deletions

View File

@ -59,3 +59,19 @@ go work use ./example
# Generate a TLS/SSL cert. Get GOPATH from `go env`.
go run 'C:\Program Files\Go\src\crypto\tls\generate_cert.go' --rsa-bits=2048 --host=localhost
```
## Testing
```powershell
# Get basic test coverage, per file.
go test -cover ./...
# Generate a coverage report by method and function.
go test -coverprofile='profile.out' ./...
# Read the report and output to the command line.
go tool cover -func='profile.out'
# Read the report and output to HTML.
go tool cover -func='profile.out'
# Generate a coverage report with number of times each statement is executed during testing.
# Use -covermode=atomic if running any tests in parallel.
go test -covermode=count -coverprofile='profile.out' ./...
```