Here is my simple interface
and an enum
that implements
it. I have written a very simple JUnit Test case
, which fails because of NullPointerException
. I do not understand why this Exception
is thrown. I have constructed an enum
object in the test class.
public interface Account {
public String getName();
public boolean isBillable();
}
public enum NonBillableAccount implements Account {
SICK_LEAVE("SickLeave"),
VACATION("Vacation"),
BUSINESS_DEVELOPMENT("businessDevelopment");
private String leaveType;
private NonBillableAccount(String leavetype) {
this.leaveType = leavetype;
}
@Override
public String getName() {
return this.leaveType;
}
@Override
public boolean isBillable() {
return false;
}
}
And the JUnit test case
here
public class NonBillableAccountTest {
Account ac = null;
@Before
public void setUp() throws Exception {
Account ac = NonBillableAccount.BUSINESS_DEVELOPMENT;
}
@Test
public void testGetName() {
assertEquals(ac.getName(),"businessDevelopment");
}
@Test
public void testIsBillable() {
assertEquals(ac.isBillable(), false);
}
}