2014-06-05 3 views
6

Sono in esecuzione Scala 2.10.3 e sbt 0.13.5 e seguendo vagamente lo scala sbt tutorial di Twitter ho riscontrato un problema minore. Il test dell'unità non verrà eseguito affatto.Sbt non eseguirà i test ScalaTest

mia build.sbt:

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

la mia classe di test:

package com.twitter.sample 

import collection.mutable.Stack 
import org.scalatest._ 

object SimpleParserSpec extends FlatSpec with Matchers { 
    "SimpleParser" should "work with basic tweet" in { 
    val parser = new SimpleParser 
    val tweet = """{"id":1, "text":"foo"}""" 
    parser.parse(tweet) match { 
     case Some(parsed) => { 
     parsed.text should be ("foo") 
     parsed.id should be (1) 
     } 
     case _ => fail("didn't parse tweet") 
    } 
    } 
} 

e questo è l'uscita di esecuzione sbt test nella cartella del progetto:

[info] Loading global plugins from C:\Users\Slench\.sbt\0.13\plugins 
[info] Set current project to twitter-sbt (in build file:/C:/Users/Slench/Desktop/twitter-sbt/) 
[info] Run completed in 36 milliseconds. 
[info] Total number of tests run: 0 
[info] Suites: completed 0, aborted 0 
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0 
[info] No tests were executed. 
[success] Total time: 0 s, completed 05-06-2014 20:19:11 

Sono non sai cosa sta andando storto, tutti i file sono nelle cartelle corrette, tutto si compila senza errori o avvertimenti s, eppure non eseguirà il mio test ... Qualche aiuto?

risposta

5

Cambia il tuo SimpleParserSpec da object a class e dovrebbe funzionare.

In particolare il cambiamento della linea

//bad 
object SimpleParserSpec extends FlatSpec with Matchers 

a

//good 
class SimpleParserSpec extends FlatSpec with Matchers 
+0

Yup che ha funzionato, grazie –

+0

Qual è la ragione perché questo cambiamento opere? –