java - How to reinitialize static finals while unit testing -


i writing unit tests class, has static final variable. however, since state of static final var modified in each test, need way reinitialize it.

how possible? need use sort of custom classloader?

variable initialized -

  static final countdownlatch latch = new countdownlatch(1); 

of course can hack around reflection or class loading, "if you, wouldn't starting form here." mutable statics evil (even called singletons). so, design code better "parameterisation above" - pass object need them, rather doing hardwired or using directory service.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -