How can I have a custom test dir?

At present I have a tests dir; but I want to change its name and still have cargo test find it. Can this be done?

I believe you should be able to change that with the [[test]] target:

# Cargo.toml
path = "other_dir"

Though, I've never done it. And I'd recommend just making a sub directory in the tests directory.

1 Like

I tried that and got

error: failed to parse manifest at `/home/mark/app/uxf/rs/Cargo.toml`

Caused by:
  test target is required

Also an explicit name for the target

name = "test"
path = "other_dir"

That produced a different error. It doesn't matter; I was mostly just curious. Thanks.

You can't change the folder cargo searches for tests in. Each [[test]] section defines a single test. If you want to move the tests into another folder you have to manually create a new [[test]] section for each new test you want to run, as far as I know.

OK, thanks, I'll stick with the baked in folder.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.