我在测试方法之外有以下方法
private DynamicBuild getSkippedBuild() { DynamicBuild build = mock(DynamicBuild.class); when(build.isSkipped()).thenReturn(true); return build; }
org.mockito.exceptions.misusing.UnfinishedStubbingException: Unfinished stubbing detected here: -> at LINE BEING CALLED FROM E.g. thenReturn() may be missing. Examples of correct stubbing: when(mock.isOk()).thenReturn(true); when(mock.isOk()).thenThrow(exception); doThrow(exception).when(mock).someVoidMethod(); Hints: 1. missing thenReturn() 2. you are trying to stub a final method,you naughty developer!
当你在测试方法之外存在时,看起来mockito不高兴.这不受支持吗?
编辑:我可以通过在@Test方法中进行存根来实现这一点,但我想重用@Tests中的存根.