Question for all the @rustlang hackers out there -- Do you prefer #[cfg(test)] stuff in your crate, or code in the tests/*.rs files for testing the majority of your code when your library is almost entirely public API?
13
2
1
14
As per convention. Unit Tests as #[cfg(test)], integration tests into tests/ ๐Ÿ™ƒ
2
2
Hmmm ๐Ÿค” Depends on the implementation. But if it's really public API, use tests/ , it ticks enough boxes, I guess, especially if it's a crate.
1
1
I think that's a good way of thinking about it yes. Right now all my testing is doctests because I just wrote those while writing the crate - but I feel I ought to have more formal testing too.

Jan 20, 2020 ยท 10:35 PM UTC

1
1
Yea. Every internal helper / function into unit tests, desired behaviour of your public api in tests/ with all corner cases. That should be sufficient. ๐Ÿ™‚
1