help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: ERT conventions?


From: Marcin Borkowski
Subject: Re: ERT conventions?
Date: Sun, 06 Sep 2015 08:10:15 +0200

On 2015-09-06, at 07:27, Alexis <flexibeast@gmail.com> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> Hi all,
>>
>> I'm learning the ERT package.  I'd like to know whether there 
>> are any conventions/good practices regarding writing tests. 
>> Eg., should they be written in a file separate from the package? 
>> (I guess yes, for obvious reasons.)  Are there any standards for 
>> the name of that file?  In general: could anyone using ERT (or 
>> any other testing facility, for that matter) share some 
>> experiences worth knowing?
>
> i've found ERT pretty easy to use. For `org-vcard`, i've put the 
> test suite in a single file within a distinct 'tests' folder, 
> which also contains a 'data' folder containing various data 
> sources for the tests to run on:

Thanks!

And it's not that ERT is difficult to use, no.  What I'm asking is (for
instance): is it better to say

(ert-deftest my-function-test ()
  "Tests the `my-function' function."
  (with-temp-buffer
    (insert "input")
    (goto-char (point-min))
    (should (this-be-satisfied)
    (should (that-be-satisfied)))))

or maybe

(ert-deftest my-function-test ()
  "Tests the `my-function' function."
  (should (with-temp-buffer
            (insert "input")
            (goto-char (point-min))
            (this-be-satisfied)))
  (should (with-temp-buffer
            (insert "input")
            (goto-char (point-min))
            (that-be-satisfied))))

?

The former avoids code repetition and probably is (a bit) faster; the
latter /might/ result in better reporting.

Etc.

> Alexis.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

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