How to run a specific test or all tests from a specified file in Go?
Hi everyone! Just started learning Go and writing tests for my package. I have a file `math_utils_test.go` that contains several test functions: `TestAdd`, `TestSubtract`, and `TestMultiply`. I want to run only one of them, for example `TestAdd`. I tried the command `go test -run TestAdd`, but it runs all tests that have "TestAdd" in their name, even from other files. And how do I run all tests from only one specific file `math_utils_test.go`, ignoring the rest? I tried `go test math_utils_test.go`, but I get an error that it cannot find functions from the main code. My main code is in `math_utils.go`. Please advise how to do this correctly? \n\nHere is an example of my project structure:\n\n```\nmypackage/\n├── math_utils.go\n├── math_utils_test.go\n├── string_utils.go\n└── s
No answers yet.
Log in to leave an answer