You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So the below with GuiceOneServerPerSuite is fine but switching that to GuiceOneServerPerTest means the application is null in beforeAll():
importorg.scalatest.BeforeAndAfterEachimportorg.scalatestplus.play._importorg.scalatestplus.play.guice._importplay.api.Configurationimportplay.api.test.InjectingclassBeforeAndAfterextendsPlaySpecwithInjectingwithGuiceOneServerPerSuitewithBeforeAndAfterEach {
"How do I get dependencies in before and after" should {
"2 + 2 = 4" in{
assert((2+2) ==4)
valplayConfig= inject[Configuration]
println(playConfig)
}
}
overrideprotecteddefbeforeEach():Unit= {
valplayConfig= inject[Configuration]
println(playConfig)
}
overrideprotecteddefafterEach():Unit= {
valplayConfig= inject[Configuration]
println(playConfig)
}
}
But the below fails with a null pointer in beforeEach:
**Exception encountered when invoking run on a nested suite.
java.lang.NullPointerException
at play.api.test.Injecting.inject(Helpers.scala:631)
at play.api.test.Injecting.inject$(Helpers.scala:630)
at BeforeAndAfter.inject(BeforeAndAfter.scala:7)
at BeforeAndAfter.beforeEach(BeforeAndAfter.scala:22)**
importorg.scalatest.BeforeAndAfterEachimportorg.scalatestplus.play._importorg.scalatestplus.play.guice._importplay.api.Configurationimportplay.api.test.InjectingclassBeforeAndAfterextendsPlaySpecwithInjectingwithGuiceOneServerPerTestwithBeforeAndAfterEach {
"How do I get dependencies in before and after" should {
"2 + 2 = 4" in{
assert((2+2) ==4)
valplayConfig= inject[Configuration]
println(playConfig)
}
}
//runs fine if below commented outoverrideprotecteddefbeforeEach():Unit= {
valplayConfig= inject[Configuration]
println(playConfig)
}
overrideprotecteddefafterEach():Unit= {
valplayConfig= inject[Configuration]
println(playConfig)
}
}
The text was updated successfully, but these errors were encountered:
So the below with
GuiceOneServerPerSuite
is fine but switching that toGuiceOneServerPerTest
means the application is null inbeforeAll()
:But the below fails with a null pointer in
beforeEach
:The text was updated successfully, but these errors were encountered: