score:0

Accepted answer

Solved this.

Tried to replace lazy val with def, as answered in this question: Testing: FakeApplication ignoring additionalConfiguration

Which solved the problem.

Would love if someone could explain why?

score:0

This problem bit me because I was holding on to Application state in the code. Since tests typically each get their own FakeApplication, squireled-away state from one FakeApplication instance, when used in the context of another FakeApplication instance, will lead to problems. A concrete example is play.api.Play.current - this needs to be re-evaluated for each FakeApplication instance and shouldn't be held (after being evaluated only once) in your code.


Related Query

More Query from same tag