all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jorgen Schaefer <forcer@forcix.cx>
To: Nic Ferrier <nferrier@ferrier.me.uk>
Cc: emacs-devel@gnu.org
Subject: Re: Best practice for mocking functions/prompts/etc.
Date: Sun, 9 Nov 2014 09:59:09 +0100	[thread overview]
Message-ID: <20141109095909.709d26ff@forcix> (raw)
In-Reply-To: <87lhnlmgdd.fsf@ferrier.me.uk>

On Sat, 08 Nov 2014 23:17:50 +0000
Nic Ferrier <nferrier@ferrier.me.uk> wrote:

> Jorgen Schaefer <forcer@forcix.cx> 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	other threads:[~2014-11-09  8:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-08 18:34 Best practice for mocking functions/prompts/etc Jorgen Schaefer
2014-11-08 23:17 ` Nic Ferrier
2014-11-09  8:59   ` Jorgen Schaefer [this message]
2014-11-09 10:36     ` Nic Ferrier
2014-11-09 11:05       ` Jorgen Schaefer
2014-11-09  0:56 ` Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141109095909.709d26ff@forcix \
    --to=forcer@forcix.cx \
    --cc=emacs-devel@gnu.org \
    --cc=nferrier@ferrier.me.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.