import org.junit.*; import static org.junit.Assert.*; import java.util.Arrays; public class Fixtures { private int[] myData; @Before public void setup() { myData = new int[] {1, 2, 3, 4, 5}; } @After public void cleanup() { myData = null; } @Test public void testIsSorted() { final String TESTWHAT = "{1, 2, 3, 4, 5} is sorted"; int[] mdcopy = myData.clone(); Arrays.sort(mdcopy); assertTrue(TESTWHAT, Arrays.equals(mdcopy, myData)); } /** This test will fail if it DOESN'T throw a NumberFormatException */ @Test(expected=NumberFormatException.class) public void testNumberFormatException1() { Integer.parseInt("testing is fun"); } /** This test will fail if it DOES throw a NumberFormatException */ @Test public void testNumberFormatException2() throws NumberFormatException { Integer.parseInt("12345"); } }