cargo-extract-test

Crates.iocargo-extract-test
lib.rscargo-extract-test
version0.1.1
created_at2025-08-11 15:29:56.788333+00
updated_at2025-08-11 15:52:19.093667+00
descriptionA Cargo subcommand to extract and run a single test function in isolation.
homepagehttps://github.com/zk4x/cargo-extract-test
repositoryhttps://github.com/zk4x/cargo-extract-test
max_upload_size
id1790345
size12,263
(zk4x)

documentation

https://docs.rs/cargo-extract-test

README

cargo-extract-test

A Cargo subcommand to extract, compile and run a single test function in isolation.

๐Ÿš€ Purpose

cargo-extract-test allows you to:

Extract a specific test function from your project.

Compile and run it in isolation using cargo test --test.

Quickly debug or isolate failing tests without compiling and running the entire test suite.

โš™๏ธ Installation

Option 1: Local Installation

๐Ÿงช Usage

To extract and run a specific test function:

cargo extract-test <test_function_name> [-- <cargo test args>]

For example:

cargo extract-test my_test_function -- --nocapture

This command:

Extracts my_test_function into a temporary test file.

Runs it using cargo test --test __temp_test, passing any additional arguments.

๐Ÿ”„ How It Works

The tool searches your project's source and test directories for the specified test function.

It copies the test function and any necessary use statements into a temporary file.

It compiles and runs the test in isolation, providing immediate feedback.

๐Ÿ“ฆ Dependencies

walkdir: For recursively searching directories.

๐Ÿงช Example

Given a test function:

#[cfg(test)]
mod tests {
    #[test]
    fn my_test_function() {
        assert_eq!(2 + 2, 4);
    }
}

Running:

cargo extract-test my_test_function -- --nocapture

Will extract and run my_test_function in isolation.

๐Ÿ“„ License

This project is licensed under the MIT License.

Commit count: 0

cargo fmt