Description
#[cfg(test)]
is not set when running integration tests. That page says:
[Integration tests] use your library in the same way any other code would, which means they can only call functions that are part of your library’s public API.
But that sounds to me more like it's talking about pub
, pub(crate)
and so on.
There's an unsatisfying workaround but it would be a lot simpler if #[cfg(test)]
was simply enabled for integration tests. (Here's another person tripping up on this.)
The only reason not to do that seems to be a philosophical objection to using hidden APIs in integration tests. I don't agree with that. I'm sure others don't. But even if you subscribe to that philosophy you can simply not use the #[cfg(test)]
functions in your integration tests (or don't export them). The situation for people who don't subscribe to that philosophy is much more awkward.
Changing this behaviour would also fix #45599.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status