title: Mocking lombok @Getter fields with Mockito
body: <p>I am using <code>@Getter</code> notation with Lombok on some of my static fields as such:</p>
  
  <pre><code>public class A {
  
      @Getter protected static MyClass myClass;
  }
  </code></pre>
  
  <p>While unit testing, I have to mock the value of these static fields for a section of code that does:</p>
  
  <pre><code>MyClass.getMyClass();
  </code></pre>
  
  <p>To mock, I'm doing:</p>
  
  <pre><code>mock(MyClass.class);
  when(MyClass.getMyClass()).thenReturn(...);
  </code></pre>
  
  <p>However, such mock gives below error.</p>
  
  <pre><code> [testng] org.mockito.exceptions.misusing.MissingMethodInvocationException:
   [testng] when() requires an argument which has to be 'a method call on a mock'.
   [testng] For example:
   [testng]     when(mock.getArticles()).thenReturn(articles);
   [testng]
   [testng] Also, this error might show up because:
   [testng] 1. you stub either of: final/private/equals()/hashCode() methods.
   [testng]    Those methods *cannot* be stubbed/verified.
   [testng]    Mocking methods declared on non-public parent classes is not supported.
   [testng] 2. inside when() you don't call method on mock but on some other object.
  </code></pre>
  
  <p>I must be hitting condition 2, but I'm not understanding how I am not "calling method on mock". </p>
  
  <p>Has anyone successfully mocked Lombok getters?</p>
  
  <p>Thanks!</p>