/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package cobain; import junit.framework.TestCase; /** * * @author budsus */ public class CobaJUnitAspectTest extends TestCase { public CobaJUnitAspectTest(String testName) { super(testName); } @Override protected void setUp() throws Exception { super.setUp(); } @Override protected void tearDown() throws Exception { super.tearDown(); } // TODO add test methods here. The name must begin with 'test'. For example: // public void testHello() {} public void testKeranjang() { Inventori inv = new Inventori(); Barang item1 = new Barang("1", 20); Barang item2 = new Barang("2", 30); Barang item3 = new Barang("3", 40); Barang item4 = new Barang("4", 30); inv.addItem(item1); inv.addItem(item2); inv.addItem(item3); inv.addItem(item4); assertEquals("Jumlah barang di Inventori harusnya 4", 4, inv.totalItem()); Keranjang k = new Keranjang(); OperasiKeranjang.addShoppingCartItem(k, inv, item1); OperasiKeranjang.addShoppingCartItem(k, inv, item2); OperasiKeranjang.addShoppingCartItem(k, inv, item3); assertEquals("Jumlah barang di Keranjang harusnya 3", 3, k.totalItem()); assertEquals("Jumlah barang di Inventori harusnya 1", 1, inv.totalItem()); OperasiKeranjang.removeShoppingCartItem(k, inv, item2); assertEquals("Jumlah barang di Keranjang harusnya 2", 2, k.totalItem()); assertEquals("Jumlah barang di Inventori harusnya 2", 2, inv.totalItem()); } }