package com.github.eulerlcs.jmr.algorithm; import java.util.List; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; public class TestArrayList { @BeforeClass public static void setUpBeforeClass() throws Exception { } @AfterClass public static void tearDownAfterClass() throws Exception { } @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void test_foreach() { List<Integer> list = new ArrayList<>(); list.add(1); list.add(2); list.add(3); int sum = 0; for (Integer item : list) { sum += item; } Assert.assertEquals(sum, 6); } }