尝试为以下外观提出 JUnit 测试 - 我知道这应该很简单,但我一直空白。任何能让我朝着正确方向前进的想法。它不需要很复杂——我只需要完成它。
package business;
import domain.Items;
import services.exceptions.ItemNotFoundException;
import services.itemservice.IItemsService;
public class Itemmgr {
@SuppressWarnings("static-access")
public void store(Items item) {
Factory factory = Factory.getInstance(IItemsService.NAME);
IItemsService storeItem = (IItemsService)factory.getInstance(IItemsService.NAME);
storeItem.storeItem(item);
}
public void get(Items item) throws ClassNotFoundException, ItemNotFoundException {
Factory factory = Factory.getInstance(IItemsService.NAME);
@SuppressWarnings("static-access")
IItemsService getItem = (IItemsService)factory.getInstance(IItemsService.NAME);
try {
getItem.getItems("pens", 15, "red", "gel");
} catch (ClassNotFoundException | ItemNotFoundException e) {
e.printStackTrace();
System.out.println("Error - Class or Item Not Found");
}
}
}