当我从 test.java 文件运行时,JUnit 测试不会运行
我在使用 JUnit4 和 Eclipse 时遇到了一个相当奇怪的问题。
我有一个 Quaternion.java 文件和一个关联的 QuaternionTest.java。在包资源管理器中,我可以右键单击 QuaternionTest.java 文件和 Run-As JUnit 下的 (C) 图标。测试按预期运行。当我右键单击 QuaternionTest.java 文件并尝试运行测试时,出现以下错误:
An internal error occurred during: "Launching java".
Path must include project and resource name: /QuaternionTest.java
我是 Eclipse 和 JUnit 的新手,如果这应该是显而易见的,请原谅我。我尝试查看属性,但没有看到任何内容。另外,如果我从构建路径中排除 QuaternionTest.java,一切都会运行良好(当然,四元数测试除外)
任何想法都将受到高度赞赏。
I have a rather odd problem w/ JUnit4 and Eclipse.
I have a Quaternion.java file, and an associated QuaternionTest.java. In the package explorer, I can right click on the (C) icon under the QuaternionTest.java file and Run-As JUnit. The test runs as expected. When I right click on the QuaternionTest.java file and try to run the test, I get the following error:
An internal error occurred during: "Launching java".
Path must include project and resource name: /QuaternionTest.java
I'm new to Eclipse and JUnit, so forgive me if this is supposed to be obvious. I've tried looking at the properties and don't see anything. Also, if I exclude QuaternionTest.java from my build path, everything runs fine (except, of course, the Quaternion tests)
Any ideas would be most appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果没有完整的环境,此类问题总是很难调试,但听起来您的运行配置已损坏或与您的类不匹配或类似的东西。尝试删除运行配置并重试。
当您选择 Run As JUnit 时,Eclipse 将创建特定于您的 JUnit 类的运行配置。
要解决此问题,请在 Eclipse 中打开“运行”->“运行配置”。在左侧列表中,找到适用于 QuaternionTest 的运行配置,确保它是 JUnit 部分中的运行配置。删除它(右键单击,选择删除)。然后再试一次。
This sort of problem is always difficult to debug without your full environment, but it sounds like you have a Run Configuration which is corrupted or doesn't match your classes or something like that. Try deleting the Run Configuration and retrying.
When you select Run As JUnit, Eclipse creates a Run Configuration specific to your JUnit class.
To fix this, in Eclipse, open Run->Run Configuration. In the list at the left, find the run configuration that applies to QuaternionTest, make sure it's the Run Configuration in the JUnit section. Delete it (right click, select delete). Then try again.
我处理这个问题一个小时,最后我通过运行配置-> JUnit-> yourTest 来解决它。在您的测试设置中更改测试运行程序并且它可以工作。
I dealt with this problem for an hour and finally I got it worked by going to run configuration->JUnit->yourTest. In your test setting change the test runner and it works.