2013-04-30 50 views
2

我試圖運行我與annoatqaion測試,每ScalaTest網站:ScalaTest - JUnitRunner無法找到

import org.scalatest.FunSuite 
import org.hamcrest.Matchers._ 
import org.hamcrest.MatcherAssert._ 
import org.junit.runner.RunWith 
import org.scalatest.junit.JUnitRunner 
import scala.Predef.String 


@RunWith(classOf[JUnitRunner]) 

我收到以下錯誤消息,當我嘗試建立:

error: not found: object classOf 
@RunWith(classOf[JUnitRunner]) 

error: annotation argument needs to be a constant; found: <error: <none>>[JUnitRunner] 
@RunWith(classOf[JUnitRunner]) 

如果我刪除註釋,測試也運行,但我認爲註釋的要點是允許更好的運行環境從JUnit ...任何幫助將大大appreaciated

回答

4

刪除此imp ORT,使其工作:

import scala.Predef.String 

Predef所有成員是由編譯器自動導入你,除非你手動導入這樣的選擇之一。 classOfPredef的成員,並以這種方式隱藏。

1

將以下依賴項添加到您的pom.xml文件中。

<dependency> 
     <groupId>org.specs2</groupId> 
     <artifactId>specs2-junit_2.11</artifactId> 
     <version>3.8.9</version> 
     <scope>test</scope> 
    </dependency>