-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Allow @DynamicPropertySource
on non-static methods
#24825
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
Comments
Unfortunately, it is not currently possible to make the If we were to implement #16647, it may become possible, but at this time it is not possible. Have you considered applying |
|
Well, if we were to support Spring components that consume the dynamic properties would typically be initialized with such dynamic properties when the Perhaps something like test-scoped beans (see #18606) would better suit your needs? |
Ok, so but testscoped beans have been closed without any implementation? Is it maybe possible to declare my service that makes use of the "dynamic" |
That's correct. That issue was bulk closed due to lack of interest.
That's what I had in mind. Your use case reminded me of that test-scoped bean proposal. And your use case would likely be a candidate for re-opening that issue. So feel free to request that it be reopened if you feel strongly about it, and we can revisit the idea. |
@DynamicPropertySource
on non-static fields
@DynamicPropertySource
on non-static fields@DynamicPropertySource
on non-static methods
While
@DynamicPropertySource
is great, it would be even better if it could be executed on each@Test
method instead only one time at start of the test class.For example: okhttp
MockWebServer
starts on a free random port. But each test needs its ownMockWebServer
as otherwise the state is preserved between test runs.If I'd make the
MockWebServer
astatic
field, that won't work if multiple@Test
classes make use of the mock. EgassertEquals(1, mockServer.getRequestCount());
would only be valid for the first test method, as mockwebserver preserves the state then.The text was updated successfully, but these errors were encountered: