Play 2.5 Unit testing controller failed with ScalaTestPlus

544 views
Skip to first unread message

Tianhao Li

unread,
Mar 7, 2016, 1:43:29 AM3/7/16
to play-framework
val request = fakeRequest("POST", "/user").withJsonBody(Json.parse(
      s
"""{"first_name": "Alice",
        |  "
last_name": "Doe",
        |  "
credentials": {
        |    "
username": "alice",
        |    "
password": "secret"
        |  }
        |}"""
.stripMargin))
    val apiResult
= call(testController.createUser, request)

In my controller unit test, I got something like above before.

However when I upgrade to Play 2.5, I got some error:

could not find implicit value for parameter mat: akka.stream.Materializer

However, when I did like docs, 


I still have some error like no such method error about FakeApplication for ScalaTestPlus.

Anyone has idea about this?

WHY I got so many broken changes after upgrading to Play 2.5??????

César Luis Alvargonzález

unread,
Apr 8, 2016, 6:17:49 AM4/8/16
to play-framework
It looks like you are importing the wrong WithApplication:

You should import:
import play.api.test.WithApplication

and no:
import play.test.WithApplication
Reply all
Reply to author
Forward
0 new messages