Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Test() changes program flow #2

Open
dbaggerman opened this issue Aug 23, 2018 · 1 comment
Open

Test() changes program flow #2

dbaggerman opened this issue Aug 23, 2018 · 1 comment
Assignees

Comments

@dbaggerman
Copy link
Contributor

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.

@ojkelly
Copy link
Contributor

ojkelly commented Aug 23, 2018

panic and recover in the test, sounds like a better way to handle that.

You've covered the reason why Test() was added, so if we can handle this feature in a more idiomatic/stable way we should.

Do you mind making a PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants