Crate antithesis_sdk

source ·

Modules§

  • The assert module enables defining test properties about your program or workload.
  • The lifecycle module contains functions which inform the Antithesis environment that particular test phases or milestones have been reached.
  • Convenience to import all macros and functions
  • The random module provides functions that request both structured and unstructured randomness from the Antithesis environment.

Macros§

  • Assert that condition is true every time this function is called, and that it is called at least once. The corresponding test property will be viewable in the Antithesis SDK: Always group of your triage report.
  • assert_always_greater_than(x, y, ...) is mostly equivalent to assert_always!(x > y, ...), except Antithesis has more visibility to the value of x and y, and the assertion details would be merged with {"left": x, "right": y}.
  • assert_always_greater_than_or_equal_to(x, y, ...) is mostly equivalent to assert_always!(x >= y, ...), except Antithesis has more visibility to the value of x and y, and the assertion details would be merged with {"left": x, "right": y}.
  • assert_always_less_than(x, y, ...) is mostly equivalent to assert_always!(x < y, ...), except Antithesis has more visibility to the value of x and y, and the assertion details would be merged with {"left": x, "right": y}.
  • assert_always_less_than_or_equal_to(x, y, ...) is mostly equivalent to assert_always!(x <= y, ...), except Antithesis has more visibility to the value of x and y, and the assertion details would be merged with {"left": x, "right": y}.
  • Assert that condition is true every time this function is called. The corresponding test property will pass even if the assertion is never encountered. This test property will be viewable in the Antithesis SDK: Always group of your triage report.
  • assert_always_some({a: x, b: y, ...}) is similar to assert_always(x || y || ...), except:
  • Assert that a line of code is reached at least once. The corresponding test property will pass if this macro is ever called. (If it is never called the test property will therefore fail.) This test property will be viewable in the Antithesis SDK: Reachablity assertions group.
  • Assert that condition is true at least one time that this function was called. (If the assertion is never encountered, the test property will therefore fail.) This test property will be viewable in the Antithesis SDK: Sometimes group.
  • assert_sometimes_all({a: x, b: y, ...}) is similar to assert_sometimes(x && y && ...), except:
  • assert_sometimes_greater_than(x, y, ...) is mostly equivalent to assert_sometimes!(x > y, ...), except Antithesis has more visibility to the value of x and y, and the assertion details would be merged with {"left": x, "right": y}.
  • assert_sometimes_greater_than_or_equal_to(x, y, ...) is mostly equivalent to assert_sometimes!(x >= y, ...), except Antithesis has more visibility to the value of x and y, and the assertion details would be merged with {"left": x, "right": y}.
  • assert_sometimes_less_than(x, y, ...) is mostly equivalent to assert_sometimes!(x < y, ...), except Antithesis has more visibility to the value of x and y, and the assertion details would be merged with {"left": x, "right": y}.
  • assert_sometimes_less_than_or_equal_to(x, y, ...) is mostly equivalent to assert_sometimes!(x <= y, ...), except Antithesis has more visibility to the value of x and y, and the assertion details would be merged with {"left": x, "right": y}.
  • Assert that a line of code is never reached. The corresponding test property will fail if this macro is ever called. (If it is never called the test property will therefore pass.) This test property will be viewable in the Antithesis SDK: Reachablity assertions group.

Constants§

  • A constant provided by the SDK to report the location of logged output when run locally. This constant is the name of an environment variable ANTITHESIS_SDK_LOCAL_OUTPUT. ANTITHESIS_SDK_LOCAL_OUTPUT is a path to a file that can be created and written to when running locally. If this environment variable is not present at runtime, then no assertion and lifecycle output will be attempted.

Functions§

  • Global initialization logic. Performs registration of the Antithesis assertion catalog. This should be invoked as early as possible during program execution. It is recommended to call it immediately in main.