JUnitTestBuddyInfo

JUnitTestBuddyInfo - [email protected] public void testGetPhoneNumber...

Info iconThis preview shows pages 1–2. 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 JUnitTestBuddyInfo { p private BuddyInfo b; p @Before public void setUp(){ b = new BuddyInfo(); } @After public void tearDown() throws Exception { b = null; } public void testBuddyInfo(){ b.setName("Chris"); b.setAddress("Ottawa"); b.setPhoneNumber("6131231234"); b.setAge(20); BuddyInfo bi = new BuddyInfo(b); B assertTrue(bi.equals(b)); } @Test public void testSetName() { b.setName("Chris"); assertTrue(b.getName().equals("Chris")); b.setName("John"); assertTrue(b.getName().equals("John")); } @Test public void testGetName() { b.setName("Chris"); assertTrue(b.getName().equals("Chris")); b.setName("John"); assertTrue(b.getName().equals("John")); } @Test public void testGetAddress() { b.setAddress("Ottawa"); assertFalse(b.getAddress().equals("where ever")); assertTrue(b.getAddress().equals("Ottawa"));
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a } @Test public void testGetPhoneNumber() { b.setPhoneNumber("6131231234"); assertTrue(b.getPhoneNumber().equals("6131231234")); } @Test public void testSetPhoneNumber() { b.setPhoneNumber("6131231234"); assertTrue(b.getPhoneNumber().equals("6131231234")); } @Test public void testGreeting() { assertTrue(b.greeting().equals("Hello World!")); } @Test public void testSetAge() { b.setAge(15); assertTrue(b.getAge()==15); b.setAge(17); assertFalse(b.getAge()==15); } @Test public void testGetAge() { b.setAge(20); assertTrue(b.getAge()==20); assertFalse(b.getAge()==16); b.setAge(16); assertTrue(b.getAge()==16); assertFalse(b.getAge()==15); } @Test public void testIsOver18() { b.setAge(20); assertTrue(b.isOver18()); b.setAge(16); assertFalse(b.isOver18()); } }...
View Full Document

This note was uploaded on 04/13/2010 for the course SYSC 2101 taught by Professor Babac during the Winter '10 term at Carleton CA.

Page1 / 2

JUnitTestBuddyInfo - [email protected] public void testGetPhoneNumber...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online