title: How do I JUnit test a constructor?
body: <p>This test runs but fails. Not sure why? There is a class Submarine with length 1.</p>
  
  <pre><code>@Test   
  public void testShipConstructor() {
      assertTrue(Submarine.length == 1);      
  }
  </code></pre>
  
  <p>Here is the code for the class:</p>
  
  <pre><code>public abstract class Ship {
  
      private int size;
      public static int length;
  
      protected Ship(int size, String type, String shortForm) {
          this.size = size;
          this.setType(type);
          this.shortForm = shortForm;
      }
  
      public static void setLength(int length) {
      }
  
      public int getLength() {
          return length;
      }
  
      int getSize() {
          return size;
      }
  }
  
  public class Submarine extends Ship {
  
      private final static int SIZE = 1;
  
      /**
       * * Constructor, sets inherited length variable.
       */
      public Submarine() {
          super(SIZE, "Submarine", "#");
      }
  }
  </code></pre>