We are currently using the TestMain function to setup and teardown test-containers in our integration tests. This allows us to prepare the environment once for the entire test suite and save time.
We also monitor our test CI step by using gotestsum which practically parses the output from go test -json. This lets us keep the CI snappy.
One issue we are having is that there is no way to monitor TestMain's timing or outcome. In gotestsum there is some code to add a fake test case in the case the failure occurred in TestMain (see comment by @dnephin ). But, there is still no way to monitor how long did the logic before and after the tests ran.
There are several possible ways to tackle this IMO: