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
Add extension / annotation for restoring system properties #574
Comments
Related (via #381 (comment)): |
This is a good proposal, I like it. Generally speaking, the system property extension already stores and resets extensions so we can probably reuse some of that machinery.
To your questions:
|
I'm interested in taking a pass at this one if no one else has. I read through your contribution guide - It is excellent! I may have to copy some of those ideas back to my project... |
Welcome @eeverman and thank you! 😊 Looking forward to your contribution. I'll assign you this ticket and mark it as in progress. Let us know if you need any help. Feel free to open a WIP PR for that if you want to share some code. |
…es (#574 / #700) To allow users to modify environment variables and system properties directly in their test code, outside of the existing clear and set annotations, this PR introduces `RestoreEnvironmentVariables` and `RestoreSystemProperties` to revert these resources to their pre-test state. Closes: #574 PR: #700
Based on #381 (comment)
In some situations the existing annotations for clearing and setting system properties are not sufficient:
@ClearSystemProperty
is considered too error-prone (especially when setting multiple system properties)It would therefore be useful to have an annotation which captures the current system properties before the test execution (obtained via
System.getProperties()
), copies them and then restores them to this state after the test execution.The name of the annotation could for example be
@RestoreSystemProperties
. This is the same name used by System Rules, but it is quite accurate.Considerations / open questions:
@ClearSystemProperty
and@SetSystemProperty
?If so, it should be checked if there are any corner cases where this could cause issues.
String
keys and values. It is probably not worth it add any special handling for them (such as performing deep copies), however the documentation should then document this behavior.Probably, would definitely be useful.
The text was updated successfully, but these errors were encountered: