Sergey Potapov

A word from rustacean, rubist and linuxoid.

How to Run Rust Tests Automatically

If you prefer to use TDD approach to write Rust code like I do, you would need a fast feedback from your tests.

TDD cycle

Running cargo test every time you change a code base, quickly becomes a routine task. But you can automate this using cargo-watch plugin:

cargo watch -x test

Now cargo test will run automatically on every change in the source files.

However it can be still inconvenient, because you need to switch between your text editor and a terminal to see a result.

To overcome the problem we can use desktop notifications, so I’ve decided to create another small cargo plugin cargo-testify.

You can install it with the following command:

cargo install cargo-testify

And then run it within your rust project:

cargo testify

It detects changes in source files, run tests, and shows friendly desktop notifications, just like in the GIF below: