在 Netbeans 中的测试中找不到公共方法(无法编译的代码)(但可以从命令行运行)
我想测试已经有测试的类中的公共方法。
public class LocalDb {
private final static LocalDb INSTANCE = new LocalDb();
public synchronized static LocalDb getInstance() {
...
return INSTANCE;
}
private LocalDb() {
}
public boolean getSomething(){
}
public void justForTest(){
}
}
然而,在我的测试中,当我执行 LocalDb.getInstance().justForTest()
时,我得到 symbol not find
而 LocalDb.getInstance().getSomething()<找到 /code> 并且此测试类中的其他测试运行良好。
两者之间的唯一区别是 getSomething 是几个月前创建的,而 justForTest 刚刚创建。在测试类中无法“找到”新方法,但可以在代码中的其他任何地方找到它。
编辑:如果我从命令行使用 mvn -Dtest=LocalDbTest#testJustForTest test
我不会收到 Netbeans 中出现的“无法编译的代码:找不到符号”错误,并且测试会成功。
我还尝试删除项目“目标”目录,“清理并构建”项目,重新启动 Netbeans,重新启动计算机。
怎么了 ?我正在使用 Netbeans 12.8。
任何帮助表示赞赏
I want to test a public method from a class that already has tests.
public class LocalDb {
private final static LocalDb INSTANCE = new LocalDb();
public synchronized static LocalDb getInstance() {
...
return INSTANCE;
}
private LocalDb() {
}
public boolean getSomething(){
}
public void justForTest(){
}
}
However in my test, when I do LocalDb.getInstance().justForTest()
I get symbol not found
whereas LocalDb.getInstance().getSomething()
is found and other tests within this Test Class run fine.
The only difference between the two is that getSomething was created months ago, whereas justForTest has just been created. No new method can be "found" in test class, whereas it can be found anywhereelse in code.
Edit : If I use from the command line mvn -Dtest=LocalDbTest#testJustForTest test
I don't get the "Uncompilable code : cannot find symbol" error I get in Netbeans and the test succeeds.
I also tried to delete the project "target" directory, to "clean and build" the project, to restart Netbeans, to reboot the computer.
What is happening ? I am using Netbeans 12.8.
Any help appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论