Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

object scalatest is not a member of package org

I want to write some tests for my toy project in scalatest. As I use sbt I installed scalatest via libraryDependencies += "org.scalatest" %% "scalatest" % "2.0.M5" % "test" in my project root's build.sbt. Then I created test class in src/test/scala:

package parsers

import org.scalatest.FunSuite

class BaseParserSuite extends FunSuite {

    test("test works") {
        val result = 2
        assert(result === 2)
    }
}

I run it via sbt test and it works. But the annoying thing is that on line 3 with import org.scalatest.FunSuite eclipse says:

Multiple markers at this line
    - object scalatest is not a member of package org
    - object scalatest is not a member of package org

The import part is taken from this example. So the general question is: why is it working via sbt and eclipse reports the error? And where is the imported code from org.scalatest.? Or it is not physically downloaded to my computer? And as a guess -- should I add something to .classpah eclipse file?

like image 947
Vadim Samokhin Avatar asked Jan 06 '13 14:01

Vadim Samokhin


2 Answers

You should use the sbt elcipse plugin. It generates eclipse project definitions from your sbt build definition so all the libraries needed will be on the class path. See https://github.com/typesafehub/sbteclipse#for-the-impatient

like image 100
Kim Stebel Avatar answered Sep 28 '22 16:09

Kim Stebel


I encountered the same issue and resolved by deleting the project (do not click on the delete the actual files checkbox). And then I imported the "preexisting project in workspace".

like image 36
juanchito Avatar answered Sep 28 '22 15:09

juanchito