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

Support setting and getting static fields in ReflectionTestUtils [SPR-6792] #11458

Closed
spring-issuemaster opened this issue Feb 3, 2010 · 4 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Feb 3, 2010

allnightlong opened SPR-6792 and commented


Referenced from: commits 063ef24

3 votes, 4 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 2, 2014

Stéphane Nicoll commented

Changing static fields seem a dangerous and weird thing to do. What do you think Sam Brannen?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 2, 2014

Sam Brannen commented

It is indeed potentially dangerous and likely a rather uncommon use case.

Having said that, however, ReflectionTestUtils is only available in the spring-test module. So it generally (hopefully) would not be used in production code.

So if the user has a genuine use case for this in a testing scenario, I don't think it would be harmful to introduce this functionality.

Regards,

Sam

p.s. As far as I know, this functionality is already provide by PowerMock and similar mocking frameworks.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 26, 2015

Dieter Van de Walle commented

Ah damn, just needed this functionality. One vote up! :)

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 9, 2015

Sam Brannen commented

Completed as described in GitHub commit 063ef24:

Support static fields in ReflectionTestUtils

Prior to this commit it was possible to set or get a static field using
ReflectionTestUtils but only if an instance of the target class was
available.

This commit introduces dedicated support for setting and getting static
fields in ReflectionTestUtils when only the target class is available.

Furthermore, this commit increases the robustness of
ReflectionTestUtilsTests regarding expected exceptions and simplifies
the Javadoc for ReflectionTestUtils.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.