Is there a way to specify code to be run before all the tests in the current test run? Even when running tests across deeply nested directories? e.g.
a/
a/a_test.go
b/c/
b/c/c_test.go
d_test.go
I want to write some code that runs once before and once after all the tests in files a_test.go
, c_test.go
, d_test.go
have run.
I know about TestMain, which sorta does what I want if I needed to do this at the package level, but this doesn't run before/after all the tests in subdirectories/subpackages. I want something that's one level above TestMain
.
I'm not limited to go test
, so if there's a third-party test runner that would do this for go, that would be alright as well.
I'm looking for something akin to nosetests's SetUpPackage
or pytest's session scoped fixtures.