title: Mock variable in unit test android
body: <p>Searched on google about, how to mock a variable in unit testing and seen some suggestions, for my case its not working. my scenario is,</p>
  
  <pre><code>class Keys {
  
  private static Keys sKeys;
  private String enKey = null;
  
  static synchronized sKeys getInstance() {
      if(sKeys == null) {
          sKeys = new Keys();
      }
      return sKeys;
  }
  
  Boolean isLocked() {
      if(enKey == null ) {
          return true;
      }
      return false;
    }
  }
  </code></pre>
  
  <p>This is the class, i have written. Unit test of the class is below,</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)     
  public class KeysTest {
  
  @Test
  public void isLocked_Test() {
      Keys key = Keys.getInstance();
      Key.isLocked();
     // Here in isLocked function I want to mock the enKey value to other than null
     }
  }
  </code></pre>
  
  <p>Here, i want to call isLocked function, and i want to set or mock the <strong>enKey</strong> variable value to other than null.</p>
  
  <p>How i can do that?
  Could anyone help me on that?</p>