Golang testsuites

Hi all,

I have written 10 testsuite using ozontech/allure-go in internal package I want to execute all these testsuites from main.go without using cmd I want total control of test executions. Have anyone implemented any custom code .

Hello, I don’t actually understand what you mean by testsuites but I will give an example which may help you.

We write tests that are quick enough to run in _test.go files which is the easiest way to not segregate and make a spaghetti mess of tests. In this scenario, we run

go test ./... -race -parallel

However, we all know that in some point of life, if you have 3-5 microservices (most companies may have only 1 monolith so you may not need to create E2E tests), you start to create bigger tests that kick in with multiple systems, some companies call these integration, some call them E2E, some call them system testing whatever, the common thing is 1 test case takes longer secs to finish than graceful blink of an eye.

In this case, there is nothing wrong to create /tests directory at the root. So your local workflow for running short tests become. Run everything except /tests directory or aka your huge suite that are not unit tests.

go test $(go list ./… | grep -v /tests/)

You shouldn’t have total control of test executions outside of what Go brings, Go takes care of caching, race conditions, parallelization, setup/teardown phases.

I hope it helps, in my opinion, you don’t need

Highly discouraged to use something that advertises itself as a test framework, which is already built in the language