无法在任何地方调试 Junit 测试

Unable to debug Junit test anywhere

我尝试在 STS(Spring 工具套件)中调试 junit 测试。

当我尝试在测试对象下的 class 的任何方法中执行 'step-into' 时,我得到

com.sun.jdi.InternalException: Got error code in reply:35 occurred retrieving 'this' from stack frame.

当我在 IntelliJ IDEA 中执行相同操作时,我得到

'this' is not available.

我尝试了 Using the Eclipse remote debugger throws com.sun.jdi.InternalException 中的所有方法,但结果没有任何用处。

我使用

安装了java

brew cask install adoptopenjdk8.

STS 版本为 4.7.0.RELEASE

IntelliJ IDEA 版本为 2020.1.2

JUnit 版本为 4.13

经过大量调试和隔离所有工具后,我终于发现罪魁祸首是

mock-maker-inline

我在项目的 src/test/resources/mockito-extensions 目录中添加到模拟最终 类(参考:https://www.baeldung.com/mockito-final)。

请随意评论任何更好的方法,我不必添加该行并且仍然可以模拟最终 类 + 不会得到那个异常。