2

How to use cargo expand to expand macros on test files under the tests folder in a crate?

crate
    - src
        - lib.rs
    - tests
        - my_test.rs
    Cargo.toml

cargo expand --lib --tests do not recognize them(?). --bin doesn't recognize them neither.

In my_test.rs:

#[test]
fn test_it() {
    assert!(true);
}

cargo expand --test test_it replies with error: no test target named test_it

Do I have to add something to Cargo.toml so they are included?

Netwave
  • 40,134
  • 6
  • 50
  • 93

1 Answers1

0

I was able to expand the macros in my tests using:

cargo expand --test tests, perhaps try cargo expand --test my_test

The project is similar to yours:

crate
    - src
        - lib.rs
    - tests
        - tests.rs
    Cargo.toml

Cargo version: 1.69.0-nightly

Austin
  • 1,018
  • 9
  • 20