webcompere / system-stubs

System Stubs - Test Doubles for Java System resources
MIT License
91 stars 10 forks source link

Unable to CLEAR an environment variable #44

Closed ddsharpe closed 2 years ago

ddsharpe commented 2 years ago

I need to be able to test a method where the environment variable is both set and unset. In order to create a predictable build, I need to ensure that the variable is unset or null before testing. For example, if the method uses the http_proxy environment variable, some user environments will already have this set.

I tried using the set() method with empty string and null, but neither had the desired affect.

ddsharpe commented 2 years ago

My issue... sorry.

ashleyfrieze commented 2 years ago

@ddsharpe - it would be interesting to know what caught you out. Was the EnvironmentVariables object not in the active state or something?

If there's any way we can improve the documentation to help avoid this problem, then please let me know, or offer a PR.

ddsharpe commented 2 years ago

@ashleyfrieze One of the methods buried deep in what I was trying to test was checking for both upper and lower case matches to the environment variables. When I setup SystemStub EnvironmentVariables, I only set the lower case version of the variable (which on the surface, appeared to be all the code used). The test was a success as it showed me there was more to the code than showed on the surface.