JUnit expected tag not working as expected

前端 未结 3 594
闹比i
闹比i 2020-12-13 17:42

I have the following test case in eclipse, using JUnit 4 which is refusing to pass. What could be wrong?

@Test(expected = IllegalArgumentExc         


        
3条回答
  •  天命终不由人
    2020-12-13 18:18

    Just ran this in IntelliJ using JUnit 4.4:

       @Test(expected = IllegalArgumentException.class)
       public void testExpected()
       {
           throw new IllegalArgumentException();
       }
    

    Passes perfectly.

    Rebuild your entire project and try again. There's something else that you're doing wrong. JUnit 4.4 is working as advertised.

提交回复
热议问题