emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best practice for mocking functions/prompts/etc.


From: Jorgen Schaefer
Subject: Re: Best practice for mocking functions/prompts/etc.
Date: Sun, 9 Nov 2014 09:59:09 +0100

On Sat, 08 Nov 2014 23:17:50 +0000
Nic Ferrier <address@hidden> wrote:

> Jorgen Schaefer <address@hidden> writes:
> 
> > Is there a better way? Especially one that makes it easier to check
> > if the function was called at all and with what arguments, as
> > opposed to carrying around 1-2 extra variables per mocked function?
> 
> I don't see any reason to test all those things for every interactive
> function. I think interactive working (or not) should be tested once,
> by some tests around interactive. You don't have to test that.

I am not. I am testing whether a function with some complicated logic
will ask the user for something when certain conditions are true (and
then does the right thing with what it got back from the user).

> In this example, you should just mock read-file-name. Which you're
> doing.
> 
> Using cl-letf, cl-labels, cl-flet or noflet would all be ok I think.
> 
> There are elisp mocking libs. But with lisp you don't really need
> them.

Yep. I know how I would do this in my own package, and I know how I can
do this with Emacs "on-board" libraries. The latter feels rather
cumbersome to me, so I figured I'd ask if there are recommended ways /
best practices for packages that are meant to go into the Emacs
repository that I am missing. :-)

Regards,
Jorgen



reply via email to

[Prev in Thread] Current Thread [Next in Thread]