object scalatest is not a member of package org

送分小仙女□ 提交于 2019-12-13 12:26:57

问题


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?


回答1:


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




回答2:


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".



来源:https://stackoverflow.com/questions/14182963/object-scalatest-is-not-a-member-of-package-org

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!