GoLand 2019.2 Help

Testing applications

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:

gotest

Use for running standard unit tests. For more information about go test, see Package testing.

gocheck

Use to have extended functionality of go check and running more complex tests. For more information about go check, see go check.

gobench

Use for running performance tests. For more information about gobench, see Package testing: Benchmarks.

Packages for testing

Testing scopes

Depending on scope that you want to test, you can create run/debug configurations for files, directories, and packages.

Directory

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.

Package

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.

File

Application code and test functions are in the same *_test.go file. See the main_file_test.go file in the the GitHub repository.

Testing scopes
Last modified: 21 August 2019

See Also