English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Building and Tests
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-08-19 (06:28)
From: Andrew Gacek <andrew.gacek@g...>
Subject: Re: [Caml-list] Building and Tests
One thing I find helpful is to define tests anonymously inside of a
single test group. So inside of say list_test.ml I have

let tests =
  "List" >::: [
    "Empty list should have size zero" >::
      (fun () ->
        assert_equal 0 (List.length [])) ;

    "Singleton list should have size one" >::
      (fun () ->
        assert_equal 1 (List.length [0])) ;



Then I have a single file for the project called test.ml which
includes all the module tests explicitly and runs them. For example,

let tests = "Project Tests" >:::
    List_test.tests ;
    Array_test.tests ;
    String_test.tests ;

let _ = run_test_tt_main tests

Finally in my OMakefile I have

    $(rootname $(find . -name *_test.ml))

.PHONY: test
test: $(OCamlProgram unit_test, $(OUNIT) $(FILES) $(TEST_FILES))
    ./unit_test -verbose

The end result of all of this is that when I add a new test to an
existing module, I don't have to explicitly include it to be run. The
only thing I have to do explicitly is list my module tests in the
master test.ml file, and this list rarely changes.


On 8/18/07, Robert Fischer <robert@fischerventure.com> wrote:
> Is there any kind of automation that other people have built for OUnit?
> I'm wondering if anyone has pulled together OMake or shell scripts to
> execute all the tests in multiple different files, or a test-then-build
> structure?
> ~~ Robert.
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs