Code example for ArrayList

Methods: add

0
    private ArrayList<String> names;
    private NamesAdapter namesAdapter;
 
    @Before 
    public void setUp() throws Exception { 
        names = new ArrayList<String>();
        names.add("Lauren Conrad");
        names.add("Heidi Montag");
        names.add("Kim Kardashian");
        namesAdapter = new NamesAdapter(names);
    } 
 
    @Test 
    public void testGetCount() throws Exception { 
        assertThat(namesAdapter.getCount(), equalTo(names.size()));
    } 
 
    @Test 
    public void testGetItem() throws Exception { 
        assertThat((String) namesAdapter.getItem(0), equalTo("Lauren Conrad"));
        assertThat((String) namesAdapter.getItem(1), equalTo("Heidi Montag"));