Testing
Chester Wyke November 05, 2023 Updated: April 15, 2025 #rustConditional Compilation
Install
Crate Serde
References
Cargo
Toolchain (Nightly)
String Formatting
Time
Crate Tokio
Publish Crate
rustfmt
Single file script
Snippets
CI
Pattern Type State
WASM
Create New Crate
Documentation
JSON
Pattern Builder
Testing
Working with collections of bytes
Thoughts about rust
Are we yet
OnceLock
Crate Actix Web
Stack Overflow
Crate Clap
Crate Poll Promise
Crate Insta
Tips
Create new egui project
Crate CSV
Crate egui
Iterators
Crate Tracing Subscriber
Regex
vscode
Enum Conversion
Macros
lettre
Google APIs
Frequently used links and commands
Mostly self explanatory except that running test in release mode can increase limits for things like stack overflow
For more information about these commands see cargo test -- --help
.
- Readme for rstest - To see examples of how to use it. (Not extracting the ones I use because each time I go back I find more I want to use). Documented how to do names because I keep looking it up, the name in the example is
authorized_user
(For more context search their docs that’s where it is taken from). - docs.rs for strum - To see list of things that can be done with enums by this crate
Shared module for integration tests
Source: https://doc.rust-lang.org/book/ch11-03-test-organization.html#submodules-in-integration-tests
Do tests/common/mod.rs
and not tests/common.rs
.
Click for details!
They mainly focus the extra 0 test cases that show in the output, and yes that’s annoying but what annoyed me more was the warnings that functions are not used as each file is compiled separately.
So if warnings bother you too then you probably want to ensure you ensure you put it in mod.rs
.
Testing CLI applications by running them
Source: https://rust-cli.github.io/book/tutorial/testing.html#testing-cli-applications-by-running-them
Don’t have more detailed notes other than the link because I decided to not actually run the program but just test the lib instead as the compiler will guide me to where updates need to happen instead of needing to run the test to see where updates are needed. But saving the link because I’ve looked it up quite a few times.