I've installed Play Framework 2.5 by downloading and extracting the Activator bundle version.
I used the activator command to create a new Play scala application and then entered the play console.
Inside the play console I typed console
to get the scala repl. At the prompt I tried to import WithApplication
from the play.api.test
package and got the following error
scala> import play.api.test.{WithApplication}
<console>:10: error: object WithApplication is not a member of package play.api.test
import play.api.test.{WithApplication}
I also tried to import it inside a test class created inside the test directory in ExampleControllerSpec.scala and got the same error.
import org.scalatest._
import org.scalatestplus.play._
import play.api.mvc._
import play.api.test._
import play.api.test.Helpers._
class ExampleControllerSpec extends PlaySpec {
"Example Page#index" should {
"should be valid" in new WithApplication {
}
}
}
Here is the output from the PlayConsole
$ test
[info] Compiling 1 Scala source to D:\Play\TestApp\target\scala-2.11\test-classes...
[error] D:\Play\TestApp\test\ExampleControllerSpec.scala:10: not found: type WithApplication
[error] "should be valid" in new WithApplication {
[error] ^
[error] one error found
[error] (test:compileIncremental) Compilation failed
If I look at the documentation I see that it is there https://www.playframework.com/documentation/2.5.x/api/scala/index.html#play.api.test.package
So why it doesn't work in my test class and in the scala repl ?
test
command works fine for me with the import line on a test file in the test directory. Can you post the full test file, the exact location of it, and the full command you are running? – Alvaro Carrasco