Fix tests not reverting system property and environment variable changes #578
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some of the tests related to the system property and environment variable extension were changing system properties and environment variables manually, but were not reverting the changes afterwards.
I have only added the necessary calls to remove the custom entries. A more extensive solution would be to store the existing value (if any) in a field and restore that value afterwards. However, because custom system property and environment variable names are used, there are most likely no existing old values, so that extra logic would probably be redundant.
Also, should these test classes be annotated with
@WritesSystemProperty
and@WritesEnvironmentVariable
, or was that intentionally not done to prevent spurious test success in case these annotations behave incorrectly?(And do the tests currently rely on the fact that the used system property and environment variable names are unique per test?)
Proposed commit message:
PR checklist
The following checklist shall help the PR's author, the reviewers and maintainers to ensure the quality of this project.
It is based on our contributors guidelines, especially the "writing code" section.
It shall help to check for completion of the listed points.
If a point does not apply to the given PR's changes, the corresponding entry can be simply marked as done.
Documentation (general)
.adoc
file in thedocs
folder, e.g.docs/report-entries.adoc
.adoc
files)Documentation (new extension)
docs/docs-nav.yml
navigation has an entry for the new extensionpackage-info.java
contains information about the new extensionCode
Contributing
README.md
mentions the new contribution (real name optional)I hereby agree to the terms of the JUnit Pioneer Contributor License Agreement.