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