私はJUnitテストに非常に慣れていないので、次の非常に単純なクラスをテストしようとしています。
public interface IItemsService extends IService {
public final String NAME = "IItemsService";
/** Places items into the database
* @return
* @throws ItemNotStoredException
*/
public boolean storeItem(Items items) throws ItemNotStoredException;
/** Retrieves items from the database
*
* @param category
* @param amount
* @param color
* @param type
* @return
* @throws ItemNotFoundException
*/
public Items getItems (String category, float amount, String color, String type) throws ItemNotFoundException;
}
これは私がテストのために持っているものですが、nullポインターを取得し続け、それに関する別のエラーが引数に適用されません...明らかに私は愚かなことをしていますが、それは表示されません。誰かが私を正しい方向に向けることができますか?
public class ItemsServiceTest extends TestCase {
/**
* @throws java.lang.Exception
*/
private Items items;
private IItemsService itemSrvc;
protected void setUp() throws Exception {
super.setUp();
items = new Items ("red", 15, "pens", "gel");
}
IItemsService itemsService;
@Test
public void testStore() throws ItemNotStoredException {
try {
Assert.assertTrue(itemSrvc.storeItem(items));
} catch (ItemNotStoredException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println ("Item not stored");
}
}
@Test
public void testGet() throws ItemNotStoredException {
try {
Assert.assertFalse(itemSrvc.getItems(getName(), 0, getName(), getName()));
} catch (ItemNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}