Package built only for tests with Cargo


#1

Hi,

I’m working on a create that deals with loading of shared libraries. In order to test this correctly I would like to write a integration test and place it inside tests/

I wonder now if it’s possible to build a shared lib that only gets built when doing cargo test? It would be possible to define another package inside Cargo.toml but I don’t want the shared lib to be built if the user isn’t running tests (if someone is just using the crate there is no need to build)

Is this possible to do today (Ie mark in Cargo.toml that a package should only be built during cargo test)

Cheers!


#2

dev-dependencies seem to be exactly what you are looking for (I haven’t used them yet).


#3

Nice! I will try that out. Thanks.