caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: John Christopher McAlpine <jmcalpin@nmt.edu>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Use of unit testing frameworks in OCaml
Date: Thu, 10 Sep 2015 01:18:11 +0200	[thread overview]
Message-ID: <1441840691.9319.37.camel@zotac> (raw)
In-Reply-To: <55F09806.1030507@nmt.edu>

[-- Attachment #1: Type: text/plain, Size: 2187 bytes --]

Am Mittwoch, den 09.09.2015, 14:35 -0600 schrieb John Christopher
McAlpine:
>  From what I can tell, the tests for the OCaml compiler and standard 
> libraries are all done with a fairly small framework designed 
> specifically for testing the compiler and standard libraries. Is there 
> any particular reason not to use a tool such as OUnit or Broken for 
> these tests? I am aware that adding dependencies to the compiler is 
> generally frowned upon, but these libraries could significantly improve 
> the maintainability of the core language and libraries.

The last sentence is a quite strong thesis. Recently, I was in a similar
situation as the OCaml developers, namely the need arose to create unit
tests for a fairly large project (a commercial one, so I cannot point to
it). I was considering oUnit. Finally, I dropped it, because it is not
that useful at all.

The point is that the most important function for unit-testing is
polymorphic equality, and this is a built-in. All the other stuff is
absolutely optional, and if you need it, just a matter of 10-20 lines
(e.g. for selecting unit tests from the command-line - IF this is the
applicable environment). It turns out the most useful are utility
functions like

let ( &&& ) x y = x && y
  (* logical AND without short-circuit eval *)

or

let named_check name p =
  if not p then printf "[FAILED: %s]" name;
  p

which are typically missing in unit testing frameworks because these
were once ported from imperative languages. E.g. a test could now look
like

let test0001() =
  named_check "subexpr1" (f 3 4 5 = 8)
  &&& named_check "subexpr2" (g 6 7 8 = 9)

My experience is that all the other stuff you need is highly special to
the project.

What is the gain of maintainability you get by using a framework?

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
My OCaml site:          http://www.camlcity.org
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  parent reply	other threads:[~2015-09-09 23:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-09 20:35 John Christopher McAlpine
2015-09-09 20:55 ` Sébastien Hinderer
2015-09-09 22:29   ` John Christopher McAlpine
2015-09-09 23:32     ` Daniel Bünzli
2015-09-09 23:36       ` Raoul Duke
2015-09-09 23:53   ` Hendrik Boom
2015-09-09 21:29 ` Gabriel Scherer
2015-09-10  9:22   ` Alan Schmitt
2015-09-09 23:18 ` Gerd Stolpmann [this message]
2015-09-10 10:09 ` Fabrice Le Fessant

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=1441840691.9319.37.camel@zotac \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=jmcalpin@nmt.edu \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).