I am trying to mock a Scala singleton object. In particular, I need to mock the object play.api.libs.ws.WS
used inside a service component (class under test).
U
I don't like to change the design to accommodate this kind of limitation. basically what I can get is all to change the design and then use the mock framework
//since mocking frameworks on SCALA is not support mocking singleton
//hacks are either required to change the design or ...
//I'd rather putting the mocking logic here by myself
var testUser:Option[User] = None;
def getCurrentUser(request: Request[Object]) = {
if( testUser != None ){
testUser;
}
hope it helps.