Announcement Announcement Module
Collapse
No announcement yet.
JUnit @Test(expected..) not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JUnit @Test(expected..) not working

    Hi,

    I'm using JUnit 4.7 and Spring 3.0.1. The problem is that I can't write tests that are testing that certain exceptions are thrown using the @Test(expected...) annotation.

    I've tried it with this simple scenario here:

    @Test(expected=IndexOutOfBoundsException.class)
    public void testIndexOutOfBoundsException() {
    ArrayList emptyList = new ArrayList();
    Object o = emptyList.get(0);
    }

    and I still get a failure.

    Is there something that I'm missing?

    Thanks...
Working...
X