Showing posts with label JUnit. Show all posts
Showing posts with label JUnit. Show all posts

4 November 2013

A JUnit 4 Test class

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());
    }
}

18 March 2012

NetBeans 7 new features (edit)

NetBeans 7 is approved for release now. Here's a list of new features
  • Remote glassfish interaction
  • Java 7 support
    • Maven 3 support
    • HTML 5 support
    • JSON formatter
    • Git natively integrated
    • JUnit is now an unbundled plugin (Oracle legal had problems with the old CPL license)
    • easy JPA 2 metamodel generation
    The netbeans 7/Java 7/Glassfish 3.1 combination is still a bit flaky though.

        16 November 2011

        Create a test case in Intellij IDEA

        Position yourself on the name of the class you want to create a test for and press [ALT] + [ENTER].











         

        IntelliJ will let you select your test framework (JUnit 3/4, TestNG) and you can select all methods in the original class you want to generate skeletons for (pity they forgot a select all button).