How to verify that an exception was not thrown

前端 未结 4 1131
天涯浪人
天涯浪人 2020-12-17 10:06

In my unit test using Mockito I want to verify that NullPointerException was not thrown.

public void testNPENotThrown{
    Calling calling= Mock         


        
4条回答
  •  失恋的感觉
    2020-12-17 10:53

    Generally each test case runs with a new instance so setting an instance variable will not help. So make 'throw' variable static if not.

提交回复
热议问题