I am new to junit testing and I have the following test –
public class ItemsTest extends TestCase {
private Items itemsd;
protected void setUp() throws Exception {
super.setUp();
itemsd = new Items();
}
@Test
public void testGetCategory() {
boolean result = itemsd.getCategory() != null;
Assert.assertTrue(result);
}
}
Which tests this really really simple code –
/**
* @return Returns the category.
*/
public String getCategory() {
return category;
}
Obviously I am missing something simple here?
Seems your
itemsd.getCategory()returnsnulland soresultisfalse, and so the following statement fails to assert