在 NetBeans 中运行 JUnit 测试会在返回类型已更改的方法上出现 NoSuchMethodError 错误
我在 NetBeans 中有一个带有 JUnit 测试的项目。我对依赖项目中的方法返回类型进行了更改,并且应用程序运行良好。但是,当我从 NetBeans 内部运行 JUnit 测试时,我收到 NoSuchMethodError。我确保清洁和建造。
I have a project in NetBeans with JUnit tests. I made a change to a method return type in a dependent project, and the app runs fine. But when I run the JUnit test from inside NetBeans I get a NoSuchMethodError. I made sure to clean and build.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是对调用已更改方法的类进行更改(任何更改)。然后我保存了该类,然后撤消了更改并保存了该类。然后在 NetBeans 中运行 JUnit 测试就可以了。这似乎是 NetBeans 缓存的一个错误。我以前遇到过类似的奇怪问题,我不得不关闭 NetBeans,删除 NetBeans 缓存文件夹,然后重新启动 NetBeans。但似乎对该类进行更改(然后撤消它)足以修复 NetBeans 缓存。
The solution was to make a change (any change) to the class which was making the call to the changed method. I then saved the class, then undid the change and saved the class. Then running the JUnit test inside NetBeans worked. It seems like a bug with NetBeans caching. I've had strange issues like this before and I've had to close NetBeans, delete the NetBeans cache folder, and restart NetBeans. But it seems like making a change to that class (and then undoing it) was enough to fix the NetBeans cache.