Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Test code

An unwrap in a test is the assertion. A MockClock under #[cfg(test)] is exactly the injectable the testing article asks for. Test code answers to a different standard, and rabot knows where it is.

What counts as test code

  • any item or impl item under #[cfg(test)], or a cfg that mentions test (#[cfg(any(test, feature = "test-utils"))])
  • #[test], #[tokio::test], #[rstest] and #[bench] functions
  • whole files under tests/, benches/ or examples/

What is relaxed there

The domain rules: panic-in-production, swallowed-error, dropped-error-context, untyped-error, boolean-validation, ambient-time, ambient-randomness, ambient-config, primitive-soup, primitive-field, stringly-typed-field, bypassable-constructor, free-function, vague-type-name, orphan-module, oversized-impl, too-many-parameters, sectioned-function.

What is not

Sorting, the comment rules, mock-usage, ignored-test and sleep-in-tests. A test file is still code, and the last three are about tests.

Tuning it

[tests]
relax = []                            # hold tests to the full standard
relax = ["panic-in-production"]       # relax only this one