Mockito在调试模式下执行失败问题求助
Mockito调试断点干扰测试运行问题
调试测试时发现,Mockito的正常运行会被调试断点干扰——在特定类的方法中设置断点后,测试输出结果会异常。该问题与IDE无关,远程调试时同样会出现。
示例测试代码
public class MockitoTrial { @Test public void simpleTest() { var func = Mockito.mock(Function.class); Entry<String, Integer> entry = new SimpleEntry<>("one", 1); when(func.apply(eq(Entry.class))).thenReturn(entry); assertThat(func.apply(Entry.class)).isEqualTo(entry); } }
复现步骤
在org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.interceptAbstract方法中设置断点,以调试模式重新运行上述测试,会导致测试失败。
使用的依赖库版本
assertj-core-3.22.0 junit-jupiter-api-5.8.2 mockito-core-4.5.1
内容的提问来源于stack exchange,提问作者Alfredo Diaz
相关产品推荐
相关产品推荐

