对象scalatest不是包org的成员 [英] object scalatest is not a member of package org
问题描述
sbt
我通过 libraryDependencies + =org.scalatest%%scalatest%2.0.M5%test
在我的项目根的 build.sbt
中。然后我在 src / test / scala
中创建测试类: 解析器
import org.scalatest.FunSuite
class BaseParserSuite扩展FunSuite {
test(test works){
val result = 2
assert(result === 2)
}
}
我通过 sbt test
运行它,它的工作原理。但是令人讨厌的是,在第3行与 import org.scalatest.FunSuite
eclipse说:
此行上的多个标记
- 对象scalatest不是包的成员org
- 对象scalatest不是包的成员org
import
部分取自这个例子。所以一般的问题是:为什么它通过sbt和eclipse报告错误?从 org.scalatest。
中导入的代码在哪里?还是没有物理下载到我的电脑?作为一个猜测 - 我应该添加到.classpah eclipse文件吗?
你应该使用sbt elcipse插件。它从您的sbt构建定义生成eclipse项目定义,因此所需的库将位于类路径上。请参阅 https://github.com/typesafehub/sbteclipse#for-the-impatient
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?
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
这篇关于对象scalatest不是包org的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!