Unable to test a binary project


#1

My file structure is the following:

src/
    bin/
        testing/
            mod.rs
        main.rs
    lib.rs
tests/
    test.rs

I’m looking to test a function in testing/mod.rs in tests/test.rs, so I can use cargo test.

As it stands, cargo test, and cargo run work independently. How can I test that function?


#2

Untested: declare the module in the testfile, mod bin { mod testing }}.

Alternatively make it available through the lib or write unit tests in the module.


#3

Try crate assert_cli.

May help: