Re:The internals of testing in Rust in 2018
by nixpulvis on Monday July 23, 2018 @03:51PM
(#17595419)
The accessibility of testing code in Rust is one of the best parts of the tooling IMO.
[ Parent
| on HN ]
I find this pretty nice in D. You add unittest{} blocks which you compile into or out of your binary with a compiler flag. If you add some appropriately formatted comments, ddoc also turns those into docstrings with the test as example usage.
Re:The internals of testing in Rust in 2018
by skolemtotem on Monday July 23, 2018 @07:32PM
(#17596913)
Rust takes a similar approach. For unit tests, you use the #[cfg(test)] attribute (/ pragma / directive) for conditional compilation, and #[test] to mark a function that is a unit test, which is run whenever you run the `cargo test` command. Also, any Rust code in Markdown fences in documentation is, by default, also run by `cargo test`, which you can disable for an individual code block by marking it as `rust,norun` instead of `rust`.
Re:The internals of testing in Rust in 2018
by erichdongubler on Tuesday July 24, 2018 @12:45AM
(#17598173)
Shameless plug: you can have D-ish testing blocks with a macro I published on https://crates.io as `adhesion`: https://github.com/erichdongubler/adhesion-rs