12

I have the Typesafe stack installed, including ScalaTest for Scala IDE 0.9.3. I cannot figure out how to attach it to a new project. I have other projects (from the Coursera Scala course that I just took) that use it, but I cannot use it in a new project. Importing org.scalatest._ just tells me that "object scalatest is not a member of package org." The Coursera projects have a "Referenced Libraries" element that I don't know how to reproduce. I could copy the "lib_managed" folder into a new project, but that doesn't help.

There must be an easier way to start a new project that uses Scalatest?

David Matuszek
  • 1,263
  • 1
  • 16
  • 30

3 Answers3

14

After experiencing the same situation, I went back and read the guide (http://www.scalatest.org/user_guide/using_scalatest_with_eclipse) carefully, as it was also not very clear to me... The ScalaTest plugin for Eclipse only prepares Eclipse for handling projects that reference the ScalaTest jar. And the ScalaTest jar (from what I have found) does not come with the ScalaTest Eclipse plugin, when you install the plugin. So, after the ScalaTest plugin instructions, when it says:

To use ScalaTest in your Scala project, you must download ScalaTest and include it in build path of your project

they really mean you must still download the ScalaTest jar separately and add it to your build path (Add External Jar). Or, even better, use SBT to add ScalaTest as a dependency. Either way, you do not have the jar just because you installed the Eclipse plugin.

Derrick
  • 331
  • 1
  • 8
  • 1
    +1 Exactly right! The ScalaTest jar can be downloaded [here](http://www.scalatest.org/download), then add it to the Project Properties: Java Build Path. – Brent Faust Feb 28 '13 at 02:14
  • I do not need to manually add the jar files into the project with other libraries. Why do we have to do this manually for scalatest? Just curious, is there a way to automatically add it to the Eclipse classpath library? – Iwan Satria Dec 01 '16 at 03:32
2

Perhaps you already referred to this page from the user guide, but just in case:

http://www.scalatest.org/user_guide/using_scalatest_with_eclipse

We updated this last week so it should be up to date. (And no, it doesn't require knowledge of sbt.)

Bill Venners
  • 3,549
  • 20
  • 15
  • I have definitely been looking at that. Also I've been using Eclipse for years, back when I had to add jUnit by hand. But I just have no clue how to make Eclipse recognize that I have scalatest installed. I'm guessing I have to set the build path, but I'm clueless as to how. – David Matuszek Nov 27 '12 at 21:06
  • Found it. Actually, someone here showed me where to find the appropriate command. – David Matuszek Nov 27 '12 at 21:39
  • 1
    Hi David, can you let us know what that missing piece of information was? If possible I'd like to improve the user guide page about it. Thanks. – Bill Venners Nov 28 '12 at 06:38
  • Apologies for the slow response. Basic problem is that I don't know all the Eclipse menus, and it didn't occur to me to right-click the project to bring up a contextual menu. That isn't how I add things to a Java build path. The second problem is that I didn't know which option to take from there. I kept trying to add it as a library. The final problem is finding the scaladoc jar. On one of my machines it was offered as an "external jar." On another I still have no idea where the installer put it; I had to download a project from Odersky's Coursera course, and get it from there. – David Matuszek Dec 05 '12 at 01:27
1

Adding to what has already been said:

If you have SBT installed (which you should since you are using the typesafe stack) you can follow this blog post to add the reference to the classpath for eclipse:

http://comamitc.blogspot.com/2013/01/installing-library-dependencies-using.html

This is by far the easiest way I have found to manage multiple dependencies in any of these projects. If you are using Play, you can replace the 'sbt' command with the 'play' command and accomplish the same thing.

With a build tool, you do not have to manually manage your own library dependencies and if you are planning on sharing your project / getting others involved you should go this route.

comamitc
  • 831
  • 1
  • 9
  • 14