JUnit @Test expected annotation not working

前端 未结 8 1661
孤城傲影
孤城傲影 2020-12-05 17:46

I\'ve got the following test:

@Test(expected = IllegalStateException.class)
public void testKey() {
    int key = 1;
    this.finder(key);
}
<
8条回答
  •  伪装坚强ぢ
    2020-12-05 17:49

    I had the same problem I just changed my imports statements. I removed :

    import org.junit.jupiter.api.Test;
    
    import junit.framework.TestCase;
    

    and added :

    import org.junit.Test;
    

    And it worked fine for me.

提交回复
热议问题