package webtest

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Webtest.SuiteSource

Types and functions for creating and structuring unit test suites.

Sourceexception TestFailure of string

The exception thrown by failing tests.

Sourcetype result =
  1. | Error of exn
    (*

    An unexpected error occurred in the test.

    *)
  2. | Fail of string
    (*

    An assertion failed in the test.

    *)
  3. | Pass
    (*

    The test passed.

    *)

The result of running a single testcase.

Sourcetype outcome = {
  1. label : string;
  2. result : result;
  3. time_s : float;
}

The outcome of a test: its label, result, and time taken to run.

Sourceval string_of_result : result -> string
Sourcemodule Sync : sig ... end
Sourcemodule Async : sig ... end
Sourcetype t =
  1. | TestCase of string * Async.test_fun
    (*

    A labelled single test.

    *)
  2. | TestList of string * t list
    (*

    A labelled list of tests.

    *)

A labelled wrapper around a test or list of suites.

Sourceval (>::) : string -> Sync.test_fun -> t

Convenience function to create a suite from a label and a Sync.test_fun.

Sourceval (>:~) : string -> Async.test_fun -> t

Convenience function to create a suite from a label and an Async.test_fun.

Sourceval (>:::) : string -> t list -> t

Convenience function to create a suite from a label and a list of suites.

Sourceval assert_true : ?label:string -> bool -> unit

assert_bool label value returns unit if value is true, and otherwise raises TestFailure.

Sourceval assert_equal : ?equal:('a -> 'a -> bool) -> ?label:string -> ?printer:('a -> string) -> 'a -> 'a -> unit

assert_equal a b returns unit if a is equal to b, and otherwise raises TestFailure.

Sourceval assert_raises : ?label:string -> exn -> (unit -> unit) -> unit

assert_raises e task returns unit if task () raises e, and otherwise raises TestFailure.

Sourceval assert_raises_string : ?label:string -> string -> (unit -> unit) -> unit

assert_raises_string str task returns unit if task () raises an exception e for which Printexc.to_string e = str, and otherwise raises TestFailure.