Organizing tests and helpers

I have some code in my tests folder which I'd like to split into re-usable helpers as well as the tests themselves.

From what I see in the docs, helpers should go into a tests/foo/mod.rs, but what if I want my main tests to be in tests/foo.rs?

The simple answer is just name it something else, e.g. tests/foo_helpers/mod.rs, but just wondering if there's a way to have them in one single foo.rs or somehow avoid the separate naming?

What about declaring two different modules in the same file?

Not sure what you mean there... can you give an example?

(I mean I get that you can have mod blocks within a file, but not sure how it solves this issue)

You may create a module only for helpers and put the test on the main file, but maybe I'm not sure what you're aiming to.

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.