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
{{ message }}
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
The Test() function prevents Fatal() from calling os.Exit to terminate the process, as this would be undesirable when running a test suite.
However, not calling os.Exit means that functions that would normally abort with printer.Fatal instead continue running despite the error. This means that the behaviour of a function in testing may not match it's actual behaviour.
One solution may be to panic in testing rather than continuing, which will allow the test to check the panic occurred, and recover from it. Using a terminate callback which the test code can overwrite might be even more flexible.
The text was updated successfully, but these errors were encountered:
The
Test()
function preventsFatal()
from callingos.Exit
to terminate the process, as this would be undesirable when running a test suite.However, not calling
os.Exit
means that functions that would normally abort withprinter.Fatal
instead continue running despite the error. This means that the behaviour of a function in testing may not match it's actual behaviour.One solution may be to
panic
in testing rather than continuing, which will allow the test to check the panic occurred, and recover from it. Using a terminate callback which the test code can overwrite might be even more flexible.The text was updated successfully, but these errors were encountered: