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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -