macro
Test macros through their consumer
Test generated behavior in a real consumer crate, then separately compile intentionally invalid inputs. Avoid relying solely on printed token strings or exact compiler prose; check semantic behavior and stable diagnostic fragments. The workspace includes integration tests. Example: two-crate workspace; see fixtures/proc-macro-workspace/consumer/src/bin/testing.rs. This caller is not a standalone rustc program. Expected stdout (not executed): 'ok\n' Common mistake: Treating a token snapshot as proof of correct runtime results.
Formal Syntax & Structure
rust syntaxrust
cargo test -p consumer --test behaviorWorking Example
Example Snippetrust
use teaching_macros::seven;fn main() { assert_eq!(seven!(), 7); println!("ok"); }