java - Best practices for accessing private static final values in unit tests -
if private static final value x class needed in unit test (in separate package), how should 1 go obtaining x? can think of 3 options, none of seems clean me:
1) copy x test class. fear if source's x changed, while test's x preserved, unit test still pass when should fail.
2) make x public. fear breaks encapsulation. nonetheless, in opinion best option given x final.
3) create public getter x. seems it's breaking encapsulation if x should accessed class , unit test.
i don't need access it. if private, it's used implementation detail , should invisible test. should test requirements of class, not implementation details. why ask? because, on time, implantation change (or evolve) while requirements should consistent.
Comments
Post a Comment