java 在包“<默认包>”中找到 0 个测试类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25770563/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
0 test class found in package ‘<default package>’
提问by webdigga
I have recently installed IntelliJ IDEA 13.1.4 and the jRebel plugin. I have licensed it ok and created and added configurations in catalina.bat
file.
我最近安装了 IntelliJ IDEA 13.1.4 和 jRebel 插件。我已经对其进行了许可,并在catalina.bat
文件中创建并添加了配置。
When running jRebel from within IntelliJ, it seems to be monitoring the correct directories but I get the following message:
从 IntelliJ 中运行 jRebel 时,它似乎正在监视正确的目录,但我收到以下消息:
0 test class found in package ‘'
在包 '' 中找到 0 个测试类
This then tells me that it has failed to start.
然后这告诉我它无法启动。
Does anybody know what I might need to change to get this to work?
有谁知道我可能需要改变什么才能让它发挥作用?
回答by Raj
This can be fixed by invalidating the cache.
这可以通过使缓存无效来解决。
On the main menu, choose File-> Invalidate Caches/Restart.
在主菜单上,选择File-> Invalidate Caches/Restart。
回答by Marcelo Melo
Make sure your class is declared as public and not 'default'
确保您的班级被声明为公共而不是“默认”
public class MyClassTest
as opposed to:
与:
class MyClassTest
When creating a new test class via IntelliJ shortcut the generated class was not declared as public and that caused the error.
通过 IntelliJ 快捷方式创建新的测试类时,生成的类未声明为 public 并导致错误。
回答by Sorin Ve?temean
回答by Mikhail Polishuk
Just create another folder, which will mark the directory as Sources Rootand move your executable file into this folder.
只需创建另一个文件夹,它将将该目录标记为Sources Root并将您的可执行文件移动到该文件夹中。
回答by jinan
回答by tonisives
What worked for me was deleting the .idea folder and importing the project again.
对我有用的是删除 .idea 文件夹并再次导入项目。
回答by Samya Daleh
For me this was the problem: My test folder was ./test/src/com/...
. I had marked test
as test folder, but test/src
was the right one.
对我来说,这就是问题所在:我的测试文件夹是./test/src/com/...
. 我已标记test
为测试文件夹,但它test/src
是正确的。
The "false" setting worked for me with Jintellij 2017.1.3, but not in 2018.02.
“false”设置在 Jintellij 2017.1.3 中对我有用,但在 2018.02 中无效。
回答by mlecar
I had this same issue and for me it was because TestNG plugin was not installed in Intellij. I did not choose it when installed Intellij and forgot about that.
我遇到了同样的问题,对我来说这是因为 Intellij 中没有安装 TestNG 插件。我在安装 Intellij 时没有选择它并忘记了这一点。