ScalaTest in Java Eclipse Project

I'm new to ScalaTest, and now that I have it working with Maven, of course, I would like it to work well in Eclipse. My project is a Java project, but I want to improve my Scala skills by writing tests with ScalaTest.

I understood this so that I have to right-click on my project, for example, "Customize" and "Add Scala Nature". However, this makes Eclipse try to compile all my Java files using scalac, giving me a lot of "Scala Problem" entries in the problem list. Of course, the lack of a Scala character gives me a lot of β€œobvious problems” in my project for all my Scala files. How to add Scala nature only in src / test / scala?

Greetings

Nick

+6
source share
1 answer

Perhaps the simplest solution (in your context, that is, a classic Java project without M2Eclipse and a Maven project) will have two separate projects :

  • one with only the nature of java
  • with the scala character for tst.

Since you can link the directory in the second project , you do not need to move the test sources ( src/test/scala ) from the existing set of files.
You only need to exclude src/test/scala from any compilation in the first (Java only) project.

+2
source

Source: https://habr.com/ru/post/890028/


All Articles