Skip to content

Rust library test utils 🔨

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Quadriphobs1/temp_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

temp_test - temporary test utils for rust 🔨

Build Status Documentation crates.io

A simple temporary file library for Rust. This library can create a temporary environment to test your rust cli library, run test against several commands and args even provide different environments. It uses tempfile to securely handle all temporary files.

Usage

Minimum required Rust version: 1.32.0

Add this to your Cargo.toml:

[dev-dependencies]
temp_test = "0.1.1"

Example

use clap::{Arg, App};

fn main() {
    let matches = App::new("My Super Program")
        .arg(Arg::with_name("config")
        .arg(Arg::with_name("v")
            .short('v')
            .multiple(true)
            .about("Sets the level of verbosity"))
        .subcommand(App::new("test")
            .about("controls testing features")
            .arg(Arg::with_name("debug")
                .short('d')
                .about("print debug information verbosely")))
        .get_matches();

    // do some action with the matches..
}


#[test]
fn test_example() {
    let p = temp_test::build_project("test_example").build();

    assert!(p.has_file("Cargo.toml"), "Cargo.toml file does not exist");

    let result = p.command("test").run();

    assert!(result.is_success(), "Result was unsuccessful {:?}", result);
}

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Rust library test utils 🔨

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages