Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow contexts to be used in unit testing with FakeUnleash #266

Open
markusjevringflowers opened this issue Jan 24, 2025 · 1 comment
Open

Comments

@markusjevringflowers
Copy link

markusjevringflowers commented Jan 24, 2025

Describe the feature request

I would like to be able to pass an UnleashContext to FakeUnleash.enable(), so that it matches Unleash.isEnabled()

Background

You have the FakeUnleash for unit testing, which is great. However, for things like dependency injection, and per your documentation, you will often end up with a singleton instance of FakeUnleash. Especially when you are re-using the spring context between tests. If the tests are single-threaded, this fine, as you can mutate global state without fear of interaction. However, with concurrent tests, mutating global state like this can lead to incorrect interactions.

Solution suggestions

Make FakeUnleash track and use UnleashContext so that FakeUnleash.enable() matches Unleash.isEnabled()

@gastonfournier
Copy link
Contributor

Thanks, it seems reasonable, if you'd like, feel free to open a PR with your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: For later
Development

No branches or pull requests

2 participants