liveBook · Manning

Doc test

A doc test is an automated test that compiles and runs executable code examples embedded in documentation.

How 2 Manning books explain it

Refactoring to Rust

A documentation test is an automated test generated by compiling and running executable code examples embedded in documentation.

How it is used
Validates executable public-API examples while running the ordinary Rust test suite.
How deep it goes
Explains Markdown extraction, separate-crate compilation, failure reporting, and implicit-main line-number limitations.
Examples
Uses an `add` function with passing, assertion-failing, and type-error examples.
What you can do after
Operate Cargo to validate documentation examples and interpret runtime or compilation failures.

Read how Refactoring to Rust explains doc test →

Idiomatic Rust

A doc test is an automatically generated test that compiles and executes an executable code example extracted from Rust documentation.

How it is used
Uses executable API examples as integration tests while improving library documentation.
How deep it goes
Explains automatic discovery, rustdoc preprocessing, generated main, and cargo test execution.
Examples
Demonstrates crate-level LinkedList usage, animal appends, and passing generated test output.
What you can do after
Apply it via cargo test to verify that documented Rust usage examples compile and execute.

Read how Idiomatic Rust explains doc test →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.