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
The first is a unit test, whereas the second is an integration test. You'll always want both β unit tests for private internals, and integration tests for testing the API.
1
4
Yeah, but where do I draw the line when 99% of the API is public? Do I bother with unit tests for specific testing, or do I try and cover all the code by means of integration tests? What about examples, do they count for coverage, or not? Such are my Monday evening ponderings.
2
1
Yeah that's how I feel I ought to be treating this -- the doctests just show that I've not written bad examples. I'm just trying to decide between unit tests and integration tests for this. Perhaps I should sleep on the problem :D
Jan 20, 2020 Β· 10:37 PM UTC
1


