#1117·fx

Add ability to override os.Exit for fxtest

Author: codyarayCreated Sep 9, 2023Updated May 13, 2025
Labelsenhancement

Is your feature request related to a problem? Please describe.

We have a component test library for testing services (which use an uberfx-based library) as a blackbox. For this test framework we would like to catch all errors rather than exit the process.

As a bonus, it would be extra helpful if we had a good mechanism to test the actual error too (prior to os.Exit(1) being called), but understand that's a bigger scope - as long as that error is logged using the FX logger at least we can intercept that.

Describe the solution you'd like

I'd love to have an ability to override the osExit function used, similar to what's supported internally: https://github.com/uber-go/fx/pull/792

Describe alternatives you've considered

We've added our own timeouts in our test cases that developers set separately from FX timeouts. This is a recent comment that prompted me opening this ticket when it came up in a PR on our internal component test framework: Screen Shot 2023-09-08 at 9 20 13 PM cc @ctrando

Is this a breaking change? No

Additional context n/a