@Test public void myTest() { final AppProperties props = spy(AppProperties.getInstance()); when(props.isThisEnabled()).thenReturn(true); try( final MockStatic mockStatic = mockStatic(AppProperties.class)) { mockStatic.when( () -> AppProperites.getInstance()).thenReturn(props);

    // do my test and the code that uses
    // AppProperites.getInstance()
    // now gets my spy'ed version which allows me to fake out properties

<
Previous Post
HTML, CSS, URL, Markdown and other
>
Blog Archive
Archive of all previous blog posts