title: Resetting static fields for JUnit tests
body: <p>I have a set of JUnit tests which call the main method on a Java program, passes in args and checks the output. That's fine.</p>
  
  <p>However, if the program I am testing has static values which are altered, they will remain the same between tests. This causes a problem. I have no control over exactly what the program is that is being tested, or the names used for static fields.</p>
  
  <p>How can I ensure that my Unit tests run cleanly, as if it is starting the program from scratch, without keeping those static fields. Is there a way to reset them in some way?</p>
  
  <p>If not, I will have to fire up a new process which runs the program, then check the output etc, but this seems a little overkill.</p>
  
  <p>Edit - Please note I have no control over the code which the unit tests are testing - I can't change their field names, and unfortunately, I also won't know their field names. I am thinking that makes this not possible, without starting a new process?</p>