I must be doing some thing very silly :-(
I have this very simple test in maven project test directory. I have dependency
on junit-4.5 and junit-util-4.5 in my pom file
import java.io.IOException;
import java.util.ArrayList;
import org.junit.Test;
import junit.framework.TestCase;
public class AppTest extends TestCase
{
@Test
public void testApp()
{
assertTrue( true );
}
@Test(expected=IndexOutOfBoundsException.class)
public void testOutOfBounds() {
new ArrayList<Object>().get(1);
}
}
When I issue maven package command then my tests fail saying
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.063 sec <<<
FAILURE!
testOutOfBounds(com.xx.AppTest) Time elapsed: 0 sec <<< ERROR!
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.xx.AppTest.testOutOfBounds(AppTest.java:45)
I have asked via annotation that I am expecting exception but it is not caught,
why this is happening ? it simply ignores the following line of code
[EMAIL PROTECTED](expected=IndexOutOfBoundsException.class)
Any idea what am I doing wrong, I am sure it is one of those silly things which
make you cry :-(
Thanks,
Petr