home ~ socials ~ projects ~ rss

Run A Single Unit Test With Rust cargo watch

June 2023

This is what I'm using for a script to run a single test whenever there are code changes.

#!/bin/bash

TEST_NAME=test_posts_basic
cargo watch -i "site" -x "test --lib $TEST_NAME --color always

Notes

  • --nocapture is what lets dbg!() debugging messages show up. I find that very useful when working through things

TODO

    Write up the individual parts

    Write a post about just running integration tests with --test

    Write up about about using all --lib tests

end of line
Share link:
https://www.alanwsmith.com/en/2r/xl/yt/3f/?run-a-single-unit-test-with-rust-cargo-watch