2013-12-08 52 views
0

我在運行SBT的scalatest時遇到問題。將庫添加到SBT測試文件

> test 
[info] Compiling 2 Scala sources to C:\side-work\MonadsSbt\target\scala-2.10 
\test-classes... 
[error] C:\side-work\MonadsSbt\src\test\scala\tests\TestMonadLaws.scala:4: 
object scalatest is not a member of package org 
[error] import org.scalatest._ 

這裏是我的project/build.sbt部分:

libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0" % "test" 

resolvers += "Sonatype OSS Snapshots" at 
"https://oss.sonatype.org/content/repositories/snapshots" 
+0

你碰巧在'TestMonadLaws'的範圍內有一個'org'對象嗎?如果您導入「_root_.org.scalatest._」,會發生什麼情況? –

+0

在我的'TestMonadLaws'範圍內沒有對象'org'。我嘗試了你的導入,然後運行'sbt test',但得到'對象scalatest不是程序包組織成員'。 –

回答

3

這應該是build.sbtproject/Build.scala,不project/build.sbt。後者將是構建文件的構建文件 - 「元構建文件」。

+0

工作,謝謝。我最初將我的'build.sbt'移動到這個**錯誤的位置,但是隨後基於這個註釋移動了它 - https://github.com/mpeltonen/sbt-idea/issues/177#issuecomment-28498781。改變之後,我可以運行我的測試,但是我[未發現]不能運行'gen-idea'來創建一個IntelliJ項目。 –

+0

哇!難怪人們說斯卡拉是莫名其妙的!我以前從來沒有見過。但我不使用IntelliJ,所以我無法幫助你。 –