How do I JUnit test a constrcutor?

alkutob

New Member
This test runs but fails. Not sure why? There is a class Submarine with length 1.\[code\]@Test public void testShipConstructor() { assertTrue(Submarine.length == 1); }\[/code\]Here is the code for the class:\[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\]
 
Back
Top