Mocking a constructor of class.

32 views
Skip to first unread message

Daniil Moskovtsov

unread,
Oct 22, 2013, 1:37:36 PM10/22/13
to mock...@googlegroups.com
Hey everyone.

I'm trying to solve one problem. I have a class which I want to test and it has constructor like this:

public function SomeClass(){
     init();
}

I want that init() method is never called during testing. So is there a way to mock a constructor?  

For now I use a workaround with passing parameter from test so it looks like this:

public function SomeClass(isInitWanted:Boolean = true){
if(isInitWanted){
     init();
}
}

But I hope there should be a better solution. 

PS: Thank for a great tool! :)
Reply all
Reply to author
Forward
0 new messages