Java Eclipse 项目中的 ScalaTest
我对 ScalaTest 还很陌生,现在我已经让它与 Maven 一起运行,当然我希望它也能在 Eclipse 中正常运行。我的项目是一个 Java 项目,但我想通过使用 ScalaTest 编写测试来提高我的 Scala 技能。
我明白了,所以我应该右键单击我的项目,说“配置”和“添加 Scala Nature”。然而,这样做会使 Eclipse 尝试使用 scalac 编译我的所有 Java 文件,从而在问题列表中出现很多“Scala Problem”条目。当然,由于没有 Scala 性质,我的项目中的所有 Scala 文件都会出现很多“Java 问题”条目。如何将 Scala 性质仅添加到 src/test/scala?
干杯
尼克
I'm fairly new with ScalaTest, and now that I've got it running with Maven, of course I'd like to have it working well in Eclipse as well. My project is a Java project, but I want to improve my Scala skills by writing the tests with ScalaTest.
I understood it so that I should right-click on my project, say "Configure" and "Add Scala Nature". Doing that, however, makes Eclipse try to compile all my Java files with scalac, giving me a lot of "Scala Problem" entries in the problem list. Of course, not having the Scala nature gives me a lot of "Java Problem" entries in my project for all of my Scala files. How can I add the Scala nature only to src/test/scala?
Cheers
Nik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许最简单的解决方案(在您的上下文中,即经典的 Java 项目,没有 M2Eclipse 和 Maven 项目)是拥有两个独立的项目:
由于您可以链接第二个项目中的目录,因此您不需要不必从现有文件集中移动测试源 (
src/test/scala
)。您只需从第一个(仅限 Java)项目的任何编译中排除 src/test/scala 即可。
Maybe the simplest solution (in your context, i.e. classic Java project, without M2Eclipse and a Maven project) would be to have two separate projects:
Since you can link a directory in your second project, you don't have to move the sources of the tests(
src/test/scala
) from your existing file set.You only have to exclude
src/test/scala
from any compilation in the first (Java only) project.