package tezt

  1. Overview
  2. Docs
Test framework for unit tests, integration tests, and regression tests

Install

Dune Dependency

Authors

Maintainers

Sources

tezt-4.1.0.tar.bz2
md5=88c2d9d3da75ff554599bc34cbf5acbe
sha512=e60294514ecc4a989ce663ebb306e56f654dcfaffb7dbe5e3f05f5a13c9c2ff64dadde4a77b0d9a8567a76a6a7a2b25e0940ccd2a956ffcb85ff9300bfebe3bc

Description

Published: 16 May 2024

README

Tezt

Tezt (pronounced "tezty", as in "tasty" with a "z") is a test framework for OCaml. It is well suited for writing and executing unit, integration and regression tests. It integrates well with continuous integration (CI).

Documentation

The documentation contains:

  • the API, which includes an introduction to Tezt as well as documentation for all modules;

  • the default --help, which includes how to select tests from the command-line.

Getting Started

Install

Install with opam:

opam install tezt

Write a Test

Create a file such as test/main.ml:

(* [Tezt] and its submodule [Base] are designed to be opened.
   [Tezt] is the main module of the library and it only contains submodules,
   such as [Test] which is used below.
   [Tezt.Base] contains values such as [unit] which is used below. *)
open Tezt
open Tezt.Base

(* Register as many tests as you want like this. *)
let () =
  Test.register
    (* [~__FILE__] contains the name of the file in which the test is defined.
       It allows to select tests to run based on their filename. *)
    ~__FILE__
    (* Titles uniquely identify tests so that they can be individually selected. *)
    ~title: "demo"
    (* Tags are another way to group tests together to select them. *)
    ~tags: [ "math"; "addition" ]
  @@ fun () ->
  (* Here is the actual test. *)
  if 1 + 1 <> 2 then Test.fail "expected 1 + 1 = 2, got %d" (1 + 1);
  (* Here is another way to write the same test. *)
  Check.((1 + 1 = 2) int) ~error_msg: "expected 1 + 1 = %R, got %L";
  Log.info "Math is safe today.";
  (* [unit] is [Lwt.return ()]. *)
  unit

(* Call the main function of Tezt so that it actually runs your tests. *)
let () = Test.run ()

Then create a test/dune file:

(test (name main) (libraries tezt))

You can now run your test with dune runtest. However dune runtest is limited because you cannot pass command-line arguments. Usually, you would instead run something like:

dune exec test/main.exe -- -i

This should show you:

[09:04:06.395] Math is safe today.
[09:04:06.395] [SUCCESS] (1/1) demo

The -i flag is a short-hand for --info and sets the log level so that you can see the result of the call to Log.info.

To see the list of command-line options, in particular how to select tests from the command-line, how to run them in parallel and how to produce reports, run:

dune exec test/main.exe -- --help

or just look them up in the documentation.

Dependencies (7)

  1. clap >= "0.3.0"
  2. ezjsonm >= "1.1.0"
  3. base-unix
  4. lwt >= "5.6.0"
  5. re >= "1.7.2"
  6. ocaml >= "4.12"
  7. dune >= "3.0"

Dev Dependencies (4)

  1. ocamlformat with-test & = "0.25.1"
  2. js_of_ocaml-lwt with-test
  3. js_of_ocaml with-test
  4. conf-npm with-test

Used by (59)

  1. bam
  2. bls12-381 = "18.0" | >= "19.0"
  3. dedukti >= "2.7"
  4. MlFront_Cli
  5. octez-alcotezt != "18.1"
  6. octez-bls12-381-polynomial
  7. octez-l2-libs != "18.1"
  8. octez-libs != "18.1"
  9. octez-mec
  10. octez-polynomial
  11. octez-proto-libs != "18.1"
  12. octez-protocol-017-PtNairob-libs != "18.1" & < "20.1"
  13. octez-protocol-018-Proxford-libs != "18.1"
  14. octez-protocol-019-PtParisB-libs
  15. octez-protocol-020-PsParisC-libs
  16. octez-protocol-alpha-libs != "18.1"
  17. octez-shell-libs >= "19.0"
  18. octez-smart-rollup-wasm-benchmark-lib
  19. SourceCode_ASCII
  20. tezos-baking-016-PtMumbai >= "17.1"
  21. tezos-baking-017-PtNairob
  22. tezos-baking-alpha >= "17.1"
  23. tezos-base >= "17.1"
  24. tezos-clic >= "17.1"
  25. tezos-client-016-PtMumbai >= "17.1"
  26. tezos-client-017-PtNairob
  27. tezos-client-alpha >= "17.1"
  28. tezos-client-base >= "17.1"
  29. tezos-client-base-unix >= "17.1"
  30. tezos-context >= "17.1"
  31. tezos-crypto >= "17.1"
  32. tezos-crypto-dal >= "17.1"
  33. tezos-error-monad >= "17.1"
  34. tezos-hacl >= "17.1"
  35. tezos-layer2-store >= "17.1"
  36. tezos-lwt-result-stdlib >= "17.1"
  37. tezos-mockup >= "17.1"
  38. tezos-openapi >= "20.1"
  39. tezos-p2p >= "17.1"
  40. tezos-protocol-environment >= "17.1"
  41. tezos-proxy >= "17.1"
  42. tezos-proxy-server-config >= "17.1" & != "18.1"
  43. tezos-requester >= "17.1"
  44. tezos-rpc-http-server >= "17.1"
  45. tezos-sapling >= "17.1"
  46. tezos-scoru-wasm-helpers < "17.1"
  47. tezos-shell >= "17.1"
  48. tezos-shell-services >= "17.1"
  49. tezos-signer-backends >= "17.1"
  50. tezos-stdlib >= "17.1"
  51. tezos-stdlib-unix >= "17.1"
  52. tezos-store >= "17.1"
  53. tezos-version >= "17.1"
  54. tezos-webassembly-interpreter >= "17.1"
  55. tezos-workers >= "17.1"
  56. tezt-bam
  57. tezt-performance-regression
  58. tezt-tezos != "18.1"
  59. universo

Conflicts (2)

  1. js_of_ocaml-lwt < "4.0.0"
  2. js_of_ocaml < "4.0.0"
OCaml

Innovation. Community. Security.