Search code examples
scalaplayframeworkdependenciesplayframework-2.0specs2

Scala/Play 2 - Can't get sample specs2 test to run


I'm using the Play Framework v2.04 with Scala on OS X (installed via Homebrew). Everything works as expected, however I can't seem to get the basic Hello World sample specs2 test from the Play website's documentation to run. This is the code within my /app/test/example.scala file:

import org.specs2.mutable._

import play.api.test._
import play.api.test.Helpers._

class HelloWorldSpec extends Specification {

  "The 'Hello world' string" should {
    "contain 11 characters" in {
      "Hello world" must have size(11)
    }
    "start with 'Hello'" in {
      "Hello world" must startWith("Hello")
    }
    "end with 'world'" in {
      "Hello world" must endWith("world")
    }
  }
}

However when I run play test, I get the following error:

[error] /app/test/example.scala:3: object test is not a member of package play.api

AFAIK, the test object should be a member of the play.api package (according to the API reference documentation).

Any ideas on how to resolve this?

Thanks!


Solution

  • Create test directory under the project root directory and move the example.scala from app/test to test.