emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Test 'command-completion-using-modes-p' (bug#50228)


From: Lars Ingebrigtsen
Subject: Re: [PATCH] Test 'command-completion-using-modes-p' (bug#50228)
Date: Sun, 29 Aug 2021 21:08:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Johannes Maier <johannes.maier@mailbox.org> writes:

> * There are two assertions in each of the two tests, one positive and
>   one negative.  Do you prefer one `ert-deftest' per scenario/branch (or
>   even a single one for all cases)?

We have a tendency to drop a lot of test cases in the save ert-deftest,
and I think that's fine (as long as they don't get too long -- then it's
a chore to find out what actually failed).

> * The pattern "call with-temp-buffer, maybe enable a mode, then check
>   whether a command is applicable" repeats itself.  Is creating small
>   helper functions/macros generally advised for such small tests?

It goes against all "good programming" practices to repeat ourselves
this much, so the natural inclination everybody has when programming,
even tests, is to write abstractions ten macros deep to avoid that.

Which means that the test code looks really pretty, but it's virtually
impossible to see what's actually being tested, and when something
fails, you have to poke at the harness for half an hour before you see
what's going wrong.

When it comes to writing test code, my rule is: Repeat yourself as much
as possible.  If you can't eval a test case with `C-x C-e' after a form
in Emacs, the code is too pretty.

(I know others disagree.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

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