How can I access the next private static foo field from PowerMock. I just want to check that Foo, for example, is not null, and I cannot refactor the code by adding getters.
public class Bar{ private static Foo foo = new Foo(); }
I try to use this, but it does not work:
Foo foo = Whitebox.getInternalState(bar, "foo");
You can use Spring ReflectionTestUtils.getField () for this:
Foo foo = ReflectionTestUtils.getField(Bar.class, "foo");
, , : . , , - (: ) , ; , , .
- , - , null . : , , .
, : , Powermock - "" - , , .
Source: https://habr.com/ru/post/1654922/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1654917/firebase-rules-dynamically-give-access-to-a-specific-user&usg=ALkJrhiupUefv5afczoi6c4qFeo_lcXqrQAccess to colors of OSD Windows 8/10 - c ++Understanding Schema Function - lambdaC #: get selected Windows 8.1 / 10 color theme? - c #BadMethodCallException on line Macroable.php 74: Method controller does not exist - laravel-5MatchIt Package: Combining Nearest Neighbor and Exact Matching - matchingangular2 -mdl: Layout break in components not working - angularnonnull comparison warning for link pointer - c ++CSS mapping: inline block resizing text on mobile device? - htmlC ++ function pointer return type - c ++All Articles