JUnitTestAddressBook

JUnitTestAddressBook - ab.addBuddy(bi1);...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import static org.junit.Assert.*; i import org.junit.After; import org.junit.Before; import org.junit.Test; i public class JUnitTestAddressBook { p AddressBook ab; BuddyInfo bi1; BuddyInfo bi2; B @Before public void setUp() throws Exception { ab = new AddressBook(); bi1 = new BuddyInfo("Chris","Ottawa","6131234567",15); bi2 = new BuddyInfo("John","Vancouver","6041231234",15); } @After public void tearDown() throws Exception { ab = null; bi1 = null; bi2 = null; } @Test public void testAddBuddy() { assertTrue(ab.getSize()==0);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ab.addBuddy(bi1); assertTrue(ab.getSize()==1); ab.addBuddy(bi2); assertTrue(ab.getSize()==2); } @Test public void testRemoveBuddy() { ab.addBuddy(bi1); ab.addBuddy(bi2); assertTrue(ab.getSize()==2); ab.removeBuddy(bi1); assertTrue(ab.getSize()==1); ab.removeBuddy(bi2); assertTrue(ab.getSize()==0); } @Test public void testClear(){ ab.addBuddy(bi1); ab.addBuddy(bi2); assertTrue(ab.getSize()==2); ab.clear(); assertTrue(ab.getSize()==0); assertFalse(ab.getSize()==2); } }...
View Full Document

Ask a homework question - tutors are online