Skip navigation.
 
mlRe: Creating mock of a class object
FROM : Nir Soffer
DATE : Mon Jun 05 21:44:52 2006

On 05/06/2006, at 00:30, Nir Soffer wrote:

> I'm trying to create a mock of a class, so I can fake a class 
> method, but seems that OCMock does not support this. Searching did 
> not reveal anything except one blogger that happen to have the same 
> problem.


I found a simple solution based on this article:
http://www-128.ibm.com/developerworks/library/j-mocktest.html

In short:
1. refactor the tested class to create the object we want to mock 
with a factory method
2. create a subclass of the tested class, overriding the factory 
method to return a mock object
3. test the subclass

Best Regards,

Nir Soffer

Related mailsAuthorDate
mlCreating mock of a class object Nir Soffer Jun 4, 23:30
mlRe: Creating mock of a class object Nir Soffer Jun 5, 21:44