title: How to cover private static final class members by unit test exp serialVersionUID
body: <p>I am adding unit tests to cover a legacy java projet (which i can't change),</p>
  
  <p>I know how to unit test and cover this class, i did it by adding the unit test bellow.</p>
  
  <pre><code>public class Thing implements Serializable {
  
      private static final long serialVersionUID = -1463850548670691860L;
  
      private String id;
  }
  </code></pre>
  
  <p>Unsing for example :</p>
  
  <pre><code>class ThingTest {
  
      @Test
      void testShouldNotChangeSerialVersionUID() throws NoSuchFieldException {
          final Field serialVersionUID = Thing.class.getDeclaredField("serialVersionUID");
          serialVersionUID.setAccessible(true);
  
          assertEquals(-1463850548670691860L, getField(serialVersionUID, new Thing()));
      }
  }
  </code></pre>
  
  <p>But <strong>sonar</strong> and <strong>jacoco</strong> show serialVersionUID as not covered. which is sound.</p>
  
  <p><a href="https://i.stack.imgur.com/Ea7nB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ea7nB.png" alt="enter image description here"></a></p>
  
  <p>Could you please suggest a solution to make sonar happy by covering this Field.</p>
  
  <p><em>Yes I know, i should not follow the tool but the practice.</em></p>
  
  <p>Other contraint, i can't change the visibility of serialVersionUID.</p>
  
  <p>Thanks</p>