title: Junit Test Empty Method
body: <p>I have a class called <code>NullMetricsPublisher</code>, there are a few methods inside, for example one of them <code>void publish()</code>. As the class name already indicates that the class should doing nothing. The <code>void publish()</code> method is essentially empty. </p>
  
  <pre><code>void publish() {
      // do nothing in this method
  }
  </code></pre>
  
  <p>However, we do want to unit test it, make sure no logic inside the method at all. Wondering anyone know how to test an empty method of a class in Java?</p>
  
  <p><strong><em>Note</em></strong>: Why we have <code>NullMetricsPublisher</code> in first place? We do have another class called <code>MetricsPublisher</code>, which publishes metrics to our metrics service. However, in some cases, we don't want to publish metrics to at all. The existing interface must require a <code>Publisher</code>, therefore, now we just added <code>NullMetricsPublisher</code> class to implement <code>Publisher</code>.</p>