Similar issues that I ran into recently: I had a build dependency that was only needed for tests. In the end, I built a feature for "tests" that it could be conditional on. In a sense, making this a well-defined feature might be a more flexible/orthogonal/extensible design.
This also goes back to the notion of global or well-known features as discussed in Pre-Pre-RFC: making `std`-dependent Cargo features a first-class concept.
Having it as a feature would also be nice because you could compile library targets with some additional APIs that enable integration tests to do more fine-grained things.