Skip to main content

Crate clasp_test_utils

Crate clasp_test_utils 

Source
Expand description

Common test helpers and utilities for CLASP tests

This crate provides robust test utilities including:

  • Condition-based waiting (no hardcoded sleeps)
  • Proper resource cleanup with RAII
  • Strong assertion helpers
  • Test router management
  • Value collectors for subscription testing

Structs§

TestRouter
A test router that automatically cleans up on drop
ValueCollector
Collector for subscription values with thread-safe access

Constants§

DEFAULT_CHECK_INTERVAL
Default condition check interval
DEFAULT_TIMEOUT
Default test timeout

Functions§

assert_approx_eq
Assert that two values are approximately equal (for floating point)
assert_err
Assert that a Result is Err
assert_ok
Assert that a Result is Ok and return the value
assert_some
Assert that an Option is Some and return the value
assert_that
Assert a condition with a custom message
find_available_port
Find an available TCP port for testing
find_available_udp_port
Find an available UDP port for testing
wait_for
Wait for a condition with timeout - condition-based, not time-based
wait_for_count
Wait for an atomic counter to reach a target value
wait_for_flag
Wait for a boolean flag to become true
wait_with_notify
Wait with notification - more efficient than polling