Ebazhanov / gotestingexamples

Some test writing examples in go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go testing examples

Some test writing examples in Golang.Fuzz testing will only work starting with Go 1.18.

☝️ Every folder contains a different testing method using standard libraries, convey and fuzz testing.

👉 We tried to keep it as simple as possible to make the logic behind the test as clear as possible.

How to run test:

  • make sure you are in selected folder e.g. cd compare
  • run the test by $ go test

For fuzz test :

  • run go test or go test -v
  • run go test -run=TestName(for specific test)

Troubleshooting:

  • if you have an outdated dependencies in go.mod file
    • run $ go mod tidy
  • if you have conflicts between your local Go 1.xx version and version in go.mod file
    • create new go.mod file by $ go mod init nameoftheproject

Check test coverage:

  • to check that your code is 100% covered

Print result in console:

  • run $ go test -cover -v 😎

Open result in browser:

  • run test $ go test -coverprofile=coverage.out
  • open in browser $ go tool cover -html=coverage.out

About

Some test writing examples in go.


Languages

Language:Go 100.0%