title: Avoiding unused warning for @Mocked fields in IDEA
body: <p>When I have some fields in my Unit test which are <code>@Mocked</code>:</p>
  
  <pre><code>@Mocked
  private MyService service;
  </code></pre>
  
  <p>the IDEA (and I guess Java too) produces <em>unused</em> warning, because it's never being assigned value (since it's just being populated by JMockit) - despite it's being read. I am wondering what is the correct way to avoid this warning. I can do</p>
  
  <pre><code>@SuppressWarnings("unused")
  @Mocked
  private MyService service;
  </code></pre>
  
  <p>but that would also suppress warnings when I actually stop using the field (I still want that). I can also do</p>
  
  <pre><code>@Mocked
  private MyService service = null;
  </code></pre>
  
  <p>which fixes the "unused" warning, but I get the "redundant initialization" warning instead. I can avoid that by doing</p>
  
  <pre><code>@SuppressWarnings("RedundantFieldInitialization")
  @Mocked
  private MyService service = null;
  </code></pre>
  
  <p>but that seems like too much <em>warning avoidance code</em> to be nice.</p>
  
  <p>So is there any better way to avoid the warning, avoid too verbose code and still benefit from detection of truly unused variables (=those which are never read)?</p>
  
  <hr>
  
  <p>IDEA has setting in <code>Inspections | Unused declaration</code> to add annotations whose presence will turn off the warning for given field, but it would also disable the warnings for fields which are never read, therefore is not complete solution for me.</p>