-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
app implicit is null in GuiceOneAppPerTest #107
Comments
Hi @christianri, you mean something like this? class MyTestSpec extends PlaySpec with GuiceOneAppPerTest with Injecting {
println(s"The app = $app")
...
} |
Yes, like this (or as I wrote in the ticket above: println("App object", app)) |
Perhaps you could explain your use case a bit more? |
My use case is that my play application also opens a java.net.ServerSocket. |
@christianri thanks for the additional information.
How is the class MyServerSocket @Inject()(applicationLifecycle: ApplicationLifecycle) {
val serverSocket = ??? // open the server socket somehow
applicationLifecycle.addStopHook { () =>
serverSocket.close()
Future.successful(true)
}
} That way, Play will handle the |
Yes, I have it like this, the stop hook is registered. In addition, the controller that opens the socket is also started with the App via the task module ( I tested a bit further with adding a |
Hi Scalatest team,
I seem to have the issue that the app implicit is null when using the GuiceOneAppPerTest trait for testing. When I use GuiceOneAppPerSuite it is fine. I discovered this when investigating why my dependency injection in the test did not work as expected: Link
Scala version 2.12.3, play 2.6.3 and scalatestplus-play 3.1.2.
To reproduce:
Expected result: app is defined
Actual result: app is null
If you could please investigate that is is really an issue or wrong use from my end or the g8 template. Thank you very much for this great framework!
The text was updated successfully, but these errors were encountered: