0

I will make a Junit test on the following class

public class myClass{ 
     public final static String myProp = getMyrPop();

     public static String getMyProp() {
          return "someData";
     }
}

When i try to make a test, i can't mock the function getMyProp(){}

@RunWith(PowerMockRunner.class)
@PrepareForTest(MyClass.class)
public class ExternalIdUtilsTest {
    @Before
    public void init(){
        Mockito.when(MyClass.getMyProp()).thenReturn("Albert");
    }

    @Test
    public void testOne() {
        assertEquals(1,1);
    }
}

0 Answers0