stefanbirkner / system-rules

A collection of JUnit rules for testing code which uses java.lang.System.
http://stefanbirkner.github.io/system-rules
Other
546 stars 71 forks source link

Add rule for modifying enviroment variables. #39

Closed stefanbirkner closed 8 years ago

stefanbirkner commented 8 years ago

@victornoel could you please check whether this rule fulfills your needs. Unlike your code this rule does not have a constructor that accepts a map of variables. Please tell me if you need this feature. I didn't implement it now because it adds complexity to the rule.

victornoel commented 8 years ago

It's great. Combined with a @Before method it would do the same, right?

Thank you :)

victornoel commented 8 years ago

But there is something that seems strange to me, not sure thought, originalVariables is a reference to the original environment map, not a copy, so when set() is called, isn't the object referenced by originalVariables the map that is modified?

stefanbirkner commented 8 years ago

You're right. Thanks for investigating the code.

stefanbirkner commented 8 years ago

Merged: e778307cdcd423030a42502342b0cfcc79048655