任务是在调用
以下是我的代码:
测试在
table.annotationType().getMethod("name")
时引发 NoSuchMethodException
异常。以下是我的代码:
@Mock(answer = RETURNS_DEEP_STUBS)
private Table table;
@Test(expectedExceptions = NoSuchMethodException.class)
public void testGetSupportClassesDatabaseThrowException() throws NoSuchMethodException {
String testPackageName = "com.usc.dbd.util.supporttable";
MockitoAnnotations.initMocks(this);
when(table.annotationType().getMethod("name")).thenThrow(NoSuchMethodException.class);
SupportTables.getSupportClasses(testPackageName);
}
测试在
when...
行抛出NullPointerException
异常。testCompile("org.mockito:mockito-core:2.7.17")
Table
是javax.persistence
的注释。
可能问题出在模拟Table
接口上。
我正在寻找如何测试这种情况的解决方案。
NullPointerException
,但我还没有成功地缩小依赖范围。 - Krishnan Mahadevan