users
[Top] [All Lists]

Re: [cinjug-users] File Mocks

To: CinJug <users@xxxxxxxxxx>
Subject: Re: [cinjug-users] File Mocks
From: Mark Windholtz <windholtz@xxxxxxxxx>
Date: Thu, 17 Nov 2005 12:48:00 -0500
Delivered-to: mailing list users@cinjug.org
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer; b=uLKYjd/9/5hpOqMPyU1ytXN1aTFaomvfTZEx8tz2kU9ZcWEqtcySpTX9pVtexhcIDNzUBnoXGKvwE74jb455LRobo6ea3Y39E4BsjauGnHEfjID4g6xoe/NuBCt4846wd1k7wf5sQnJIOvSBZlpjUrJDUrssWV7tc23AEbdeJVY=
In-reply-to: <000901c5eb76$897d3680$6401a8c0@CARMANI9300>
Mailing-list: contact users-help@cinjug.org; run by ezmlm
References: <000901c5eb76$897d3680$6401a8c0@CARMANI9300>

On Nov 17, 2005, at 07:57 AM, James Carman wrote:
You'd probably have to do a LOT of work to get the mock to work correctly


Yup, I know. But hey, programmers are used to working hard. :-)

When your dealing with an API without interfaces you just /have/
to work hard to break dependencies.

Luckily, File and it's methods are not 'final'.
So another possibility is to subclass File and over-ride the methods you are
interested in on a test-by-test basis. (this technique is often called a "shunt").
Inner classes can be used for creating the shunt.


If your only using a few File methods over-riding is a good enough option.
But then you still have to build an injection mechanizum to get the shunted File
from the test into the target.



-----Original Message----- From: Mark Windholtz [mailto:windholtz@xxxxxxxxx] Sent: Thursday, November 17, 2005 7:41 AM To: CinJug Subject: Re: [cinjug-users] File Mocks

Edward,

There was an effort a while back to provide Mocks for all standard
Java APIs,
but if I'm remembering right, it was stopped shortly after when
easymock.org was released.
I couldn't find links to it though.

Could you use EasyMock ?

- Mark


On Nov 16, 2005, at 09:17 PM, Edward Sumerfield wrote:

I am writing some file manipulation programs and am having problems
with testing them. Anyone know if there are some ways to mock my
Files?

Ed



Regards,
- Mark Windholtz
(513) 226-8259

railsstudio.com



---------
You may unsubscribe from this mailing list
by sending a blank email addressed to:
users-unsubscribe@xxxxxxxxxx

--
Find additional help by sending a blank email
addressed to:
users-help@xxxxxxxxxx




Regards,
- Mark Windholtz
(513) 226-8259

railsstudio.com



<Prev in Thread] Current Thread [Next in Thread>