Testing ensures that behavior of your code is correct and expected. Good-written tests allow you to develop with confidence that your code will work and will not break your existing code.
GoLand includes several packages that you can use to run your tests. Also, you can apply a specific testing scope for the selected package.
Packages for testing
For testing purposes, GoLand includes the following packages:
Use for running standard unit tests. For more information about
go test, see Package testing.
Use to have extended functionality of
go checkand running more complex tests. For more information about
go check, see go check.
Use for running performance tests. For more information about
gobench, see Package testing: Benchmarks.
Depending on scope that you want to test, you can create run/debug configurations for files, directories, and packages.
An application file and a test file are in the same directory (for example, applicationFolder/main.go and applicationFolder/main_test.go). See main.go and main_test.go files in the GitHub repository.
An application file and a test file are in a package or in a collection of related Go packages (a module). Packages must be in the go/src directory (for example, go/src/myPackage). A module is a collection of Go packages stored in a file tree with a go.mod file that lists all the related Go packages and requirements. See example files in the divisionMod directory in the GitHub repository.
Application code and test functions are in the same *_test.go file. See the main_file_test.go file in the the GitHub repository.