/
opam
89 lines (74 loc) · 2.53 KB
/
opam
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
opam-version: "2.0"
maintainer: "thomas@gazagnaire.org"
authors: "Thomas Gazagnaire"
homepage: "https://github.com/mirage/alcotest/"
dev-repo: "git+https://github.com/mirage/alcotest.git"
bug-reports: "https://github.com/mirage/alcotest/issues/"
license: "ISC"
doc: "https://mirage.github.io/alcotest/"
build: [
["jbuilder" "subst" "-p" name] {pinned}
["jbuilder" "build" "-p" name "-j" jobs]
["jbuilder" "runtest" "-p" name "-j" jobs] {with-test}
]
depends: [
"ocaml" {>= "4.02.3"}
"jbuilder" {build & >= "1.0+beta10"}
"fmt" {>= "0.8.0"}
"astring"
"result"
"cmdliner"
]
synopsis:
"Logo](https://raw.githubusercontent.com/mirage/alcotest/master/alcotest-logo.png)"
description: """
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](https://travis-ci.org/mirage/alcotest.svg)](https://travis-ci.org/mirage/alcotest)
[![docs](https://img.shields.io/badge/doc-online-blue.svg)](https://mirage.github.io/alcotest/Alcotest.html)
### Examples
A simple example:
```ocaml
(* 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.
```shell
$ ./simple.native
[OK] test_set 0 Capitalize.
[OK] test_set 1 Add entries.
Test Successful in 0.001s. 2 tests run.
```
See the [examples](https://github.com/mirage/alcotest/tree/master/examples)
folder for more examples."""
url {
src:
"https://github.com/mirage/alcotest/releases/download/0.8.0/alcotest-0.8.0.tbz"
checksum: "md5=771277ef1fe21b17920b5b44acf441b3"
}