alcotest

AuthorThomas Gazagnaire
LicenseISC
Homepagehttps://github.com/mirage/alcotest/
Issue Trackerhttps://github.com/mirage/alcotest/issues/
Maintainerthomas@gazagnaire.org
Dependencies
&astring
cmdliner
fmt>= 0.8.0
jbuilder>= 1.0+beta10
result
Availableocaml-version >= "4.02.3"
PublishedJul 23, 2017
Source [http] https://github.com/mirage/alcotest/releases/download/0.8.0/alcotest-0.8.0.tbz
771277ef1fe21b17920b5b44acf441b3
StatisticsInstalled 8 times last month.
Edithttps://github.com/ocaml/opam-repository/tree/master/packages/alcotest/alcotest.0.8.0/opam

Logo](https://raw.githubusercontent.com/mirage/alcotest/master/alcotest-logo.png)

Alcotest is a lightweight and colourful test framework.

Alcotest exposes simple interface to perform unit tests. It exposes a simple TESTABLE module type, a check function to assert test predicates and a run function to perform a list of unit -> unit test callbacks.

Alcotest provides a quiet and colorful output where only faulty runs are fully displayed at the end of the run (with the full logs ready to inspect), with a simple (yet expressive) query language to select the tests to run.

Build Status docs

Examples

A simple example:

(* Build with `ocamlbuild -pkg alcotest simple.byte` *)

(* A module with functions to test *)
module To_test = struct
  let capit letter = Char.uppercase letter
  let plus int_list = List.fold_left (fun a b -> a + b) 0 int_list
end

(* The tests *)
let capit () =
  Alcotest.(check char) "same chars"  'A' (To_test.capit 'a')

let plus () =
  Alcotest.(check int) "same ints" 7 (To_test.plus [1;1;2;3])

let test_set = [
  "Capitalize" , `Quick, capit;
  "Add entries", `Slow , plus ;
]

(* Run it *)
let () =
  Alcotest.run "My first test" [
    "test_set", test_set;
  ]

The result is a self-contained binary which displays the test results. Use ./simple.byte --help to see the runtime options.

$ ./simple.native
[OK]        test_set  0   Capitalize.
[OK]        test_set  1   Add entries.
Test Successful in 0.001s. 2 tests run.

See the examples folder for more examples.

Necessary for
alcotest-async
alcotest-lwt
anycache
>= 0.7.4
anycache-async
anycache-lwt
arp
base64
>= 2.1.2
bulletml
callipyge
capnp-rpc
capnp-rpc-lwt
0.3
ccss
>= 1.6
channel
charrua-client
charrua-client-lwt
charrua-client-mirage
cohttp
>= 0.17.0
conex
cow
>= 2.2.0
datakit
>= 0.12.0
datakit-bridge-github
>= 0.12.0
datakit-ci
datakit-client-git
>= 0.12.0
decompress
>= 0.3
depyt
dns-forward
0.9.0
dns-forward-lwt-unix
dnssd
dog
0.2.1
ezjsonm
>= 0.4.2
ezjsonm-lwt
faraday
|0.2.0
>= 0.3.0
farfadet
fat-filesystem
>= 0.12.0
functoria-runtime
>= 2.2.0
git
|&>= 1.4.10
1.4.11
>= 1.11.0
&>= 1.5.2
1.10.0
&>= 1.5.0
1.5.1
git-mirage
git-unix
>= 1.10.0
graphql
graphql-async
graphql-lwt
graphql_parser
hkdf
hvsock
irmin
|0.8.0
&>= 0.12.0
1.2.0
&>= 0.9.6
0.11.1
irmin-chunk
irmin-fs
irmin-git
irmin-http
irmin-mem
irmin-unix
>= 1.0.0
irmin-watcher
jekyll-format
jitsu
lambdoc
>= 1.0-beta4
lru
mechaml
>= 1.0.0
merge-queues
>= 0.2.0
merge-ropes
>= 0.2.0
mirage-block-ramdisk
>= 0.3
mirage-channel-lwt
mirage-flow
&>= 1.0.2
1.2.0
mirage-flow-unix
mirage-fs-unix
>= 1.2.0
mirage-logs
>= 0.3.0
mirage-nat
mirage-net-unix
>= 2.3.0
mirage-tc
mrt-format
multipart-form-data
named-pipe
opium
>= 0.15.0
opium_kernel
osx-acl
osx-attr
osx-cf
osx-fsevents
osx-membership
osx-mount
osx-xattr
pbkdf
polyglot
ppx_deriving_cmdliner
ppx_graphql
prometheus
prometheus-app
protocol-9p
>= 0.3
protocol-9p-unix
psq
rubytt
salsa20
salsa20-core
scrypt-kdf
sendmsg
tcpip
>= 2.4.2
terminal_size
>= 0.1.1
tftp
tyxml
>= 4.0.0
unix-dirent
unix-errno
>= 0.3.0
unix-fcntl
>= 0.3.0
unix-sys-resource
unix-sys-stat
unix-time
vpnkit
zlist