How to Run a Single Test
·
228 words
·
2 minutes read
Go has a simple command line for running its tests, with go test
. However, often when writing tests you don’t care about the rest of the test suite - you just want to run your new test. This post shows you the command you need to run just your test, as well as a full example below.
TL;DR: use -run
go test -run TestSub
Example:
main.go
|
|
main_test.go
|
|
Command: (We are running with the -v
parameter so we can see which tests have been run.)
go test -v -run TestSub