From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 5B2A07FACD for ; Mon, 29 Sep 2014 10:03:42 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.04,618,1406584800"; d="scan'208";a="98358015" Received: from meleze.ens.fr (HELO [129.199.99.114]) ([129.199.99.114]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 29 Sep 2014 10:03:42 +0200 Message-ID: <5429125E.7020201@inria.fr> Date: Mon, 29 Sep 2014 10:03:42 +0200 From: Francois Berenger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: caml-list@inria.fr References: <20140928230638.GT2829@cooper-siegel.org> <87zjdioqe2.fsf@gmail.com> In-Reply-To: <87zjdioqe2.fsf@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] testing private functions with oUnit On 09/29/2014 09:08 AM, Malcolm Matalka wrote: > Out of curiosity: why? Any private function should be exercised through > an API function somehow. > > IME, testing private functions often makes refactoring more painful > without a clear win in code being better tested. > > If your API is pure, btw, you should checkout QCheck for testing it > instead of unit tests. You can also use qtest (available in opam) and write your test code directly as comments in the .ml files, as is done in batteries: https://github.com/ocaml-batteries-team/batteries-included/blob/master/src/batList.mlv Look for (*$T in the code for example. > My 2 cents, > /M > > Eric Cooper writes: > >> I'd like to write unit tests for functions not exported in a .mli >> file. The only way I can see is to remove the .mli file while >> building the test, so the whole .ml file is visible. Is there a better >> way, preferably integrated with ocamlmake + findlib? >> >> -- >> Eric Cooper e c c @ c m u . e d u > -- Regards, Francois.