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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 08:39:36  来源:igfitidea点击:

0 test class found in package ‘<default package>’

javaintellij-idea

提问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.batfile.

我最近安装了 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

Source

来源

回答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 Vinod Joshi

enter image description here

在此处输入图片说明

Make sure 'app' is selected to run...

确保选择“应用程序”来运行...

回答by Sorin Ve?temean

enter image description here

在此处输入图片说明

On your topbar or Alt + Shift + F10 and Run your project with your default Configuration not "values in app"

在您的顶栏或 Alt + Shift + F10 上并使用默认配置而不是“应用程序中的值”运行您的项目

回答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

When I used the IntelliJ 'Create Test' feature, my test classes were automatically created as private.

当我使用 IntelliJ 的“创建测试”功能时,我的测试类会自动创建为私有的。

When I manually changed my test classes to public, my test classes were found.

当我手动将我的测试类更改为 public 时,我的测试类被找到了。

Source

来源

回答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 testas test folder, but test/srcwas 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 时没有选择它并忘记了这一点。