Module test

Minimal unit test runner

When --cfg test is provided as an argument to the compiler, this module will override the main entrypoint with the test runner which will run all the test cases defined in the code that is being compiled.

Each test case is executed in a subprocess.

Example

Test attributes

The following attribute is supported: #[test::ignore] to skip execution of a test (useful e.g. to make sure that a test compiles but is not run). This can be used in combination with #[cfg_attr(...)] to conditionally enable a test only on certain configurations.

Custom test frameworks

Nothing prevents you from writing your own framework, just compile with --cfg custom_test_framework. The TestCase and TEST_CASES constants are public and can be used to implement custom test runners, or they can be discovered through reflection in a different way. cases.

Modules

#[cfg] tests
Quis testabitur ipsos testes

Structs

Test case metadata
Holder for the results of a test case.

Functions

Macros

Assert that the inner block abnormally terminates the process.
Assert that the inner block panics.

Consts