« Return to Thread: Mocking concrete class via constructor call

Re: Mocking concrete class via constructor call

by Nat Pryce :: Rate this Message:

Reply to Author | View in Thread

In jMock 2, the ConcreteClassImposteriser creates mock objects of
concrete classes without calling their constructor at all. So you
don't need to provide constructor parameters.

--Nat

2009/6/30 Sam Khan <samkhanski@...>:

> Hi,
>
> I remember reading somewhere that it was possible to create a mock of a concrete
> class while calling (and providing the relevant arguments to) a particular
> constructor. I know I'm veering off the JMock path here but I'm hamstrung by not
> being able to extract and then mock interfaces (due to various reasons). For
> example, if I have the following class and constructor , can I mock it?
>
> public Resource {
>
>    public Resource(int param1, MyClass param2){
>        this.param1 = param1;
>        this.param2 = param2;
>    }
> }
>
> Thanks,
> Sam
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>



--
http://www.natpryce.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Mocking concrete class via constructor call