You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some unit tests modify global variables in the process they run in. Currently, unit tests need to restore those variables when they are completed since the same process may be used to run other unit tests.
I propose to extend testing.T with a new function ExitProcess. When a unit test calls ExitProcess, a new process will be started for subsequent unit tests.
With this change, the following test would succeed:
Tests that need to run as an independent child process should probably do so explicitly, rather than only exiting after the test.
See https://go.dev/talks/2014/testing.slide#23
Ok, does not seem like a lot of support for this, so I will close it.
Thanks for the input and the idea of starting a subprocess manually! I guess it would also be possible to get coverage reports in some way with this approach.
Some unit tests modify global variables in the process they run in. Currently, unit tests need to restore those variables when they are completed since the same process may be used to run other unit tests.
I propose to extend testing.T with a new function ExitProcess. When a unit test calls ExitProcess, a new process will be started for subsequent unit tests.
With this change, the following test would succeed:
The ExitProcess() function should probably not be supported for parallel tests.
The text was updated successfully, but these errors were encountered: