How to run all tests in repo that match a regex?

Viewed 37

I want to run all tests in a repo that have the suffix "Unit" in the name of the test. For example I have 2 tests in different subdirectory locations. While I am in the terminal in the root location of the project.

The below test is in location: ./my/unittest/location

func TestAthingUnit(t *testing.T) {
    println("*hi*")
}

The below test is in location: ./some/other

func TestSomethingElse(t *testing.T) {
    println("something else")
}

I run this command:

go test -run "^*Unit$" -v

I want only the test TestAthingUnit to run, however, it errors and says:

no go files in /my/project/path

How do I run all unit tests whose name matches a regex while in my repo/project at the root location but without having to include the folder path of the test location?

0 Answers
Related