1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | package infotool; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.*; public class InfoModelTest { private InfoModel instance; @Before public void setUp() { instance = new InfoModel(); } /** * Test of getMessage method, of class InfoModel. */ @Test public void testGetMessage() { assertEquals( "welcome to mvc" , instance.getMessage()); } /** * Test of getWeather method, of class InfoModel. */ @Test public void testGetWeather() { assertEquals( "Sunny" , instance.getWeather()); } /** * Test of setMessage method, of class InfoModel. */ @Test public void testSetMessage() { String wthString = "JUnit @Rules" ; instance.setMessage(wthString); assertEquals(wthString, instance.getMessage()); } /** * Test of setWeather method, of class InfoModel. */ @Test public void testSetWeather() { String wthString = "It's going to rain" ; instance.setWeather(wthString); assertEquals(wthString, instance.getWeather()); } /** * Test of addModelChangeListener method, of class InfoModel. */ @Test public void testAddModelChangeListener() { InfoModel instance = new InfoModel(); InfoView view = new InfoViewTestSupport(instance); instance.addModelChangeListener(view); instance.setMessage( "From testAddModelChangeListener" ); assertTrue(((InfoViewTestSupport) view).getNotification()); } } |
4 November 2013
A JUnit 4 Test class
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment