From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: ERT conventions? Date: Sun, 06 Sep 2015 08:10:15 +0200 Message-ID: <87pp1w13js.fsf@mbork.pl> References: <87r3mc16qn.fsf@mbork.pl> <878u8kce2s.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1441519860 10972 80.91.229.3 (6 Sep 2015 06:11:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Sep 2015 06:11:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Sep 06 08:10:49 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZYTA9-0002lA-79 for geh-help-gnu-emacs@m.gmane.org; Sun, 06 Sep 2015 08:10:49 +0200 Original-Received: from localhost ([::1]:45420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYTA8-0000Nw-JL for geh-help-gnu-emacs@m.gmane.org; Sun, 06 Sep 2015 02:10:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYT9t-0000N1-1J for help-gnu-emacs@gnu.org; Sun, 06 Sep 2015 02:10:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYT9o-00034H-Tp for help-gnu-emacs@gnu.org; Sun, 06 Sep 2015 02:10:32 -0400 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:42990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYT9o-000346-Mh for help-gnu-emacs@gnu.org; Sun, 06 Sep 2015 02:10:28 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id DD46C8F200C for ; Sun, 6 Sep 2015 08:10:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RzzKEW2B7gWP for ; Sun, 6 Sep 2015 08:10:23 +0200 (CEST) Original-Received: from localhost (103-115.echostar.pl [213.156.103.115]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 8F2BB8F2003 for ; Sun, 6 Sep 2015 08:10:23 +0200 (CEST) In-reply-to: <878u8kce2s.fsf@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:5e00:2:52::8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107054 Archived-At: On 2015-09-06, at 07:27, Alexis wrote: > Marcin Borkowski 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