Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define test-only dependencies?

I have a Rust library that implements a lint plugin. I want to include compiletest, but not require it outside of testing. What is the correct way to specify that the dependency is for testing only?

like image 227
llogiq Avatar asked Apr 24 '15 20:04

llogiq


People also ask

What is a test dependency?

What is Dependency Testing? Dependency Testing, a testing technique in which an application's requirements are pre-examined for an existing software, initial states in order to test the proper functionality. The impacted areas of the application are also tested when testing the new features or existing features.

What is test dependency in Maven?

A test -scoped dependency is a dependency that is available on the classpath only during test compilation and test execution. If your project has war or ear packaging, a test -scoped dependency would not be included in the project's output archive.

What are dependencies in unit testing?

So, what is a unit testing dependency? It's a dependency that you must set up in the test before you can exercise the system under test. Dependencies can be explicit, like in the example above, but they also can be implicit.


1 Answers

Yes. Use dev-dependencies. From the Cargo docs:

You can add a [dev-dependencies] section to your Cargo.toml whose format is equivalent to [dependencies]:

[dev-dependencies] tempdir = "0.3" 

Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmarks.

When possible, you should also use Cargo's resolver version 2 to better handle complicated dev-dependency cases.

like image 116
Shepmaster Avatar answered Sep 25 '22 15:09

Shepmaster