]>
Commit | Line | Data |
---|---|---|
2d4aa38b EH |
1 | # cargo-test(1) |
2 | ||
3 | ||
4 | ||
5 | ## NAME | |
6 | ||
7 | cargo-test - Execute unit and integration tests of a package | |
8 | ||
9 | ## SYNOPSIS | |
10 | ||
11 | `cargo test` [_options_] [_testname_] [`--` _test-options_] | |
12 | ||
13 | ## DESCRIPTION | |
14 | ||
15 | Compile and execute unit and integration tests. | |
16 | ||
17 | The test filtering argument `TESTNAME` and all the arguments following the two | |
18 | dashes (`--`) are passed to the test binaries and thus to _libtest_ (rustc's | |
19 | built in unit-test and micro-benchmarking framework). If you're passing | |
20 | arguments to both Cargo and the binary, the ones after `--` go to the binary, | |
21 | the ones before go to Cargo. For details about libtest's arguments see the | |
22 | output of `cargo test -- --help`. | |
23 | ||
24 | As an example, this will filter for tests with `foo` in their name and run them | |
25 | on 3 threads in parallel: | |
26 | ||
27 | cargo test foo -- --test-threads 3 | |
28 | ||
29 | Tests are built with the `--test` option to `rustc` which creates an | |
30 | executable with a `main` function that automatically runs all functions | |
31 | annotated with the `#[test]` attribute in multiple threads. `#[bench]` | |
32 | annotated functions will also be run with one iteration to verify that they | |
33 | are functional. | |
34 | ||
35 | The libtest harness may be disabled by setting `harness = false` in the target | |
36 | manifest settings, in which case your code will need to provide its own `main` | |
37 | function to handle running tests. | |
38 | ||
39 | Documentation tests are also run by default, which is handled by `rustdoc`. It | |
40 | extracts code samples from documentation comments and executes them. See the | |
41 | [rustdoc book](https://doc.rust-lang.org/rustdoc/) for more information on | |
42 | writing doc tests. | |
43 | ||
44 | ## OPTIONS | |
45 | ||
46 | ### Test Options | |
47 | ||
48 | <dl> | |
49 | ||
50 | <dt class="option-term" id="option-cargo-test---no-run"><a class="option-anchor" href="#option-cargo-test---no-run"></a><code>--no-run</code></dt> | |
51 | <dd class="option-desc">Compile, but don't run tests.</dd> | |
52 | ||
53 | ||
54 | <dt class="option-term" id="option-cargo-test---no-fail-fast"><a class="option-anchor" href="#option-cargo-test---no-fail-fast"></a><code>--no-fail-fast</code></dt> | |
55 | <dd class="option-desc">Run all tests regardless of failure. Without this flag, Cargo will exit | |
56 | after the first executable fails. The Rust test harness will run all tests | |
57 | within the executable to completion, this flag only applies to the executable | |
58 | as a whole.</dd> | |
59 | ||
60 | ||
61 | </dl> | |
62 | ||
63 | ||
64 | ### Package Selection | |
65 | ||
66 | By default, when no package selection options are given, the packages selected | |
67 | depend on the selected manifest file (based on the current working directory if | |
68 | `--manifest-path` is not given). If the manifest is the root of a workspace then | |
69 | the workspaces default members are selected, otherwise only the package defined | |
70 | by the manifest will be selected. | |
71 | ||
72 | The default members of a workspace can be set explicitly with the | |
73 | `workspace.default-members` key in the root manifest. If this is not set, a | |
74 | virtual workspace will include all workspace members (equivalent to passing | |
75 | `--workspace`), and a non-virtual workspace will include only the root crate itself. | |
76 | ||
77 | <dl> | |
78 | ||
79 | <dt class="option-term" id="option-cargo-test--p"><a class="option-anchor" href="#option-cargo-test--p"></a><code>-p</code> <em>spec</em>...</dt> | |
80 | <dt class="option-term" id="option-cargo-test---package"><a class="option-anchor" href="#option-cargo-test---package"></a><code>--package</code> <em>spec</em>...</dt> | |
81 | <dd class="option-desc">Test only the specified packages. See <a href="https://doc.rust-lang.org/cargo/commands/cargo-pkgid.md">cargo-pkgid(1)</a> for the | |
82 | SPEC format. This flag may be specified multiple times.</dd> | |
83 | ||
84 | ||
85 | <dt class="option-term" id="option-cargo-test---workspace"><a class="option-anchor" href="#option-cargo-test---workspace"></a><code>--workspace</code></dt> | |
86 | <dd class="option-desc">Test all members in the workspace.</dd> | |
87 | ||
88 | ||
89 | ||
90 | <dt class="option-term" id="option-cargo-test---all"><a class="option-anchor" href="#option-cargo-test---all"></a><code>--all</code></dt> | |
91 | <dd class="option-desc">Deprecated alias for <code>--workspace</code>.</dd> | |
92 | ||
93 | ||
94 | ||
95 | <dt class="option-term" id="option-cargo-test---exclude"><a class="option-anchor" href="#option-cargo-test---exclude"></a><code>--exclude</code> <em>SPEC</em>...</dt> | |
96 | <dd class="option-desc">Exclude the specified packages. Must be used in conjunction with the | |
97 | <code>--workspace</code> flag. This flag may be specified multiple times.</dd> | |
98 | ||
99 | ||
100 | </dl> | |
101 | ||
102 | ||
103 | ### Target Selection | |
104 | ||
105 | When no target selection options are given, `cargo test` will build the | |
106 | following targets of the selected packages: | |
107 | ||
108 | - lib — used to link with binaries, examples, integration tests, and doc tests | |
109 | - bins (only if integration tests are built and required features are | |
110 | available) | |
111 | - examples — to ensure they compile | |
112 | - lib as a unit test | |
113 | - bins as unit tests | |
114 | - integration tests | |
115 | - doc tests for the lib target | |
116 | ||
117 | The default behavior can be changed by setting the `test` flag for the target | |
118 | in the manifest settings. Setting examples to `test = true` will build and run | |
119 | the example as a test. Setting targets to `test = false` will stop them from | |
120 | being tested by default. Target selection options that take a target by name | |
121 | ignore the `test` flag and will always test the given target. | |
122 | ||
123 | Doc tests for libraries may be disabled by setting `doctest = false` for the | |
124 | library in the manifest. | |
125 | ||
126 | Binary targets are automatically built if there is an integration test or | |
127 | benchmark. This allows an integration test to execute the binary to exercise | |
128 | and test its behavior. The `CARGO_bin_EXE_<name>` | |
129 | [environment variable](../reference/environment-variables.html#environment-variables-cargo-sets-for-crates) | |
130 | is set when the integration test is built so that it can use the | |
131 | [`env` macro](https://doc.rust-lang.org/std/macro.env.html) to locate the | |
132 | executable. | |
133 | ||
134 | Passing target selection flags will test only the specified | |
135 | targets. | |
136 | ||
137 | <dl> | |
138 | ||
139 | <dt class="option-term" id="option-cargo-test---lib"><a class="option-anchor" href="#option-cargo-test---lib"></a><code>--lib</code></dt> | |
140 | <dd class="option-desc">Test the package's library.</dd> | |
141 | ||
142 | ||
143 | <dt class="option-term" id="option-cargo-test---bin"><a class="option-anchor" href="#option-cargo-test---bin"></a><code>--bin</code> <em>name</em>...</dt> | |
144 | <dd class="option-desc">Test the specified binary. This flag may be specified multiple times.</dd> | |
145 | ||
146 | ||
147 | <dt class="option-term" id="option-cargo-test---bins"><a class="option-anchor" href="#option-cargo-test---bins"></a><code>--bins</code></dt> | |
148 | <dd class="option-desc">Test all binary targets.</dd> | |
149 | ||
150 | ||
151 | ||
152 | <dt class="option-term" id="option-cargo-test---example"><a class="option-anchor" href="#option-cargo-test---example"></a><code>--example</code> <em>name</em>...</dt> | |
153 | <dd class="option-desc">Test the specified example. This flag may be specified multiple times.</dd> | |
154 | ||
155 | ||
156 | <dt class="option-term" id="option-cargo-test---examples"><a class="option-anchor" href="#option-cargo-test---examples"></a><code>--examples</code></dt> | |
157 | <dd class="option-desc">Test all example targets.</dd> | |
158 | ||
159 | ||
160 | <dt class="option-term" id="option-cargo-test---test"><a class="option-anchor" href="#option-cargo-test---test"></a><code>--test</code> <em>name</em>...</dt> | |
161 | <dd class="option-desc">Test the specified integration test. This flag may be specified | |
162 | multiple times.</dd> | |
163 | ||
164 | ||
165 | <dt class="option-term" id="option-cargo-test---tests"><a class="option-anchor" href="#option-cargo-test---tests"></a><code>--tests</code></dt> | |
166 | <dd class="option-desc">Test all targets in test mode that have the <code>test = true</code> manifest | |
167 | flag set. By default this includes the library and binaries built as | |
168 | unittests, and integration tests. Be aware that this will also build any | |
169 | required dependencies, so the lib target may be built twice (once as a | |
170 | unittest, and once as a dependency for binaries, integration tests, etc.). | |
171 | Targets may be enabled or disabled by setting the <code>test</code> flag in the | |
172 | manifest settings for the target.</dd> | |
173 | ||
174 | ||
175 | <dt class="option-term" id="option-cargo-test---bench"><a class="option-anchor" href="#option-cargo-test---bench"></a><code>--bench</code> <em>name</em>...</dt> | |
176 | <dd class="option-desc">Test the specified benchmark. This flag may be specified multiple times.</dd> | |
177 | ||
178 | ||
179 | <dt class="option-term" id="option-cargo-test---benches"><a class="option-anchor" href="#option-cargo-test---benches"></a><code>--benches</code></dt> | |
180 | <dd class="option-desc">Test all targets in benchmark mode that have the <code>bench = true</code> | |
181 | manifest flag set. By default this includes the library and binaries built | |
182 | as benchmarks, and bench targets. Be aware that this will also build any | |
183 | required dependencies, so the lib target may be built twice (once as a | |
184 | benchmark, and once as a dependency for binaries, benchmarks, etc.). | |
185 | Targets may be enabled or disabled by setting the <code>bench</code> flag in the | |
186 | manifest settings for the target.</dd> | |
187 | ||
188 | ||
189 | <dt class="option-term" id="option-cargo-test---all-targets"><a class="option-anchor" href="#option-cargo-test---all-targets"></a><code>--all-targets</code></dt> | |
190 | <dd class="option-desc">Test all targets. This is equivalent to specifying <code>--lib --bins --tests --benches --examples</code>.</dd> | |
191 | ||
192 | ||
193 | </dl> | |
194 | ||
195 | ||
196 | <dl> | |
197 | ||
198 | <dt class="option-term" id="option-cargo-test---doc"><a class="option-anchor" href="#option-cargo-test---doc"></a><code>--doc</code></dt> | |
199 | <dd class="option-desc">Test only the library's documentation. This cannot be mixed with other | |
200 | target options.</dd> | |
201 | ||
202 | ||
203 | </dl> | |
204 | ||
205 | ### Feature Selection | |
206 | ||
207 | The feature flags allow you to control the enabled features for the "current" | |
208 | package. The "current" package is the package in the current directory, or the | |
209 | one specified in `--manifest-path`. If running in the root of a virtual | |
210 | workspace, then the default features are selected for all workspace members, | |
211 | or all features if `--all-features` is specified. | |
212 | ||
213 | When no feature options are given, the `default` feature is activated for | |
214 | every selected package. | |
215 | ||
216 | <dl> | |
217 | ||
218 | <dt class="option-term" id="option-cargo-test---features"><a class="option-anchor" href="#option-cargo-test---features"></a><code>--features</code> <em>features</em></dt> | |
219 | <dd class="option-desc">Space or comma separated list of features to activate. These features only | |
220 | apply to the current directory's package. Features of direct dependencies | |
221 | may be enabled with <code><dep-name>/<feature-name></code> syntax. This flag may be | |
222 | specified multiple times, which enables all specified features.</dd> | |
223 | ||
224 | ||
225 | <dt class="option-term" id="option-cargo-test---all-features"><a class="option-anchor" href="#option-cargo-test---all-features"></a><code>--all-features</code></dt> | |
226 | <dd class="option-desc">Activate all available features of all selected packages.</dd> | |
227 | ||
228 | ||
229 | <dt class="option-term" id="option-cargo-test---no-default-features"><a class="option-anchor" href="#option-cargo-test---no-default-features"></a><code>--no-default-features</code></dt> | |
230 | <dd class="option-desc">Do not activate the <code>default</code> feature of the current directory's package.</dd> | |
231 | ||
232 | ||
233 | </dl> | |
234 | ||
235 | ||
236 | ### Compilation Options | |
237 | ||
238 | <dl> | |
239 | ||
240 | <dt class="option-term" id="option-cargo-test---target"><a class="option-anchor" href="#option-cargo-test---target"></a><code>--target</code> <em>triple</em></dt> | |
241 | <dd class="option-desc">Test for the given architecture. The default is the host | |
242 | architecture. The general format of the triple is | |
243 | <code><arch><sub>-<vendor>-<sys>-<abi></code>. Run <code>rustc --print target-list</code> for a | |
244 | list of supported targets.</p> | |
245 | <p>This may also be specified with the <code>build.target</code> | |
246 | <a href="https://doc.rust-lang.org/cargo/reference/config.html">config value</a>.</p> | |
247 | <p>Note that specifying this flag makes Cargo run in a different mode where the | |
248 | target artifacts are placed in a separate directory. See the | |
249 | <a href="https://doc.rust-lang.org/cargo/guide/build-cache.html">build cache</a> documentation for more details.</dd> | |
250 | ||
251 | ||
252 | ||
253 | <dt class="option-term" id="option-cargo-test---release"><a class="option-anchor" href="#option-cargo-test---release"></a><code>--release</code></dt> | |
254 | <dd class="option-desc">Test optimized artifacts with the <code>release</code> profile. See the | |
255 | <a href="#profiles">PROFILES</a> section for details on how this affects profile | |
256 | selection.</dd> | |
257 | ||
258 | ||
259 | ||
260 | </dl> | |
261 | ||
262 | ### Output Options | |
263 | ||
264 | <dl> | |
265 | <dt class="option-term" id="option-cargo-test---target-dir"><a class="option-anchor" href="#option-cargo-test---target-dir"></a><code>--target-dir</code> <em>directory</em></dt> | |
266 | <dd class="option-desc">Directory for all generated artifacts and intermediate files. May also be | |
267 | specified with the <code>CARGO_TARGET_DIR</code> environment variable, or the | |
268 | <code>build.target-dir</code> <a href="https://doc.rust-lang.org/cargo/reference/config.html">config value</a>. Defaults | |
269 | to <code>target</code> in the root of the workspace.</dd> | |
270 | ||
271 | ||
272 | </dl> | |
273 | ||
274 | ### Display Options | |
275 | ||
276 | By default the Rust test harness hides output from test execution to keep | |
277 | results readable. Test output can be recovered (e.g., for debugging) by passing | |
278 | `--nocapture` to the test binaries: | |
279 | ||
280 | cargo test -- --nocapture | |
281 | ||
282 | <dl> | |
283 | ||
284 | <dt class="option-term" id="option-cargo-test--v"><a class="option-anchor" href="#option-cargo-test--v"></a><code>-v</code></dt> | |
285 | <dt class="option-term" id="option-cargo-test---verbose"><a class="option-anchor" href="#option-cargo-test---verbose"></a><code>--verbose</code></dt> | |
286 | <dd class="option-desc">Use verbose output. May be specified twice for "very verbose" output which | |
287 | includes extra output such as dependency warnings and build script output. | |
288 | May also be specified with the <code>term.verbose</code> | |
289 | <a href="https://doc.rust-lang.org/cargo/reference/config.html">config value</a>.</dd> | |
290 | ||
291 | ||
292 | <dt class="option-term" id="option-cargo-test--q"><a class="option-anchor" href="#option-cargo-test--q"></a><code>-q</code></dt> | |
293 | <dt class="option-term" id="option-cargo-test---quiet"><a class="option-anchor" href="#option-cargo-test---quiet"></a><code>--quiet</code></dt> | |
294 | <dd class="option-desc">No output printed to stdout.</dd> | |
295 | ||
296 | ||
297 | <dt class="option-term" id="option-cargo-test---color"><a class="option-anchor" href="#option-cargo-test---color"></a><code>--color</code> <em>when</em></dt> | |
298 | <dd class="option-desc">Control when colored output is used. Valid values:</p> | |
299 | <ul> | |
300 | <li><code>auto</code> (default): Automatically detect if color support is available on the | |
301 | terminal.</li> | |
302 | <li><code>always</code>: Always display colors.</li> | |
303 | <li><code>never</code>: Never display colors.</li> | |
304 | </ul> | |
305 | <p>May also be specified with the <code>term.color</code> | |
306 | <a href="https://doc.rust-lang.org/cargo/reference/config.html">config value</a>.</dd> | |
307 | ||
308 | ||
309 | ||
310 | <dt class="option-term" id="option-cargo-test---message-format"><a class="option-anchor" href="#option-cargo-test---message-format"></a><code>--message-format</code> <em>fmt</em></dt> | |
311 | <dd class="option-desc">The output format for diagnostic messages. Can be specified multiple times | |
312 | and consists of comma-separated values. Valid values:</p> | |
313 | <ul> | |
314 | <li><code>human</code> (default): Display in a human-readable text format.</li> | |
315 | <li><code>short</code>: Emit shorter, human-readable text messages.</li> | |
316 | <li><code>json</code>: Emit JSON messages to stdout. See | |
317 | <a href="https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages">the reference</a> | |
318 | for more details.</li> | |
319 | <li><code>json-diagnostic-short</code>: Ensure the <code>rendered</code> field of JSON messages contains | |
320 | the "short" rendering from rustc.</li> | |
321 | <li><code>json-diagnostic-rendered-ansi</code>: Ensure the <code>rendered</code> field of JSON messages | |
322 | contains embedded ANSI color codes for respecting rustc's default color | |
323 | scheme.</li> | |
324 | <li><code>json-render-diagnostics</code>: Instruct Cargo to not include rustc diagnostics in | |
325 | in JSON messages printed, but instead Cargo itself should render the | |
326 | JSON diagnostics coming from rustc. Cargo's own JSON diagnostics and others | |
327 | coming from rustc are still emitted.</li> | |
328 | </ul></dd> | |
329 | ||
330 | ||
331 | ||
332 | </dl> | |
333 | ||
334 | ### Manifest Options | |
335 | ||
336 | <dl> | |
337 | ||
338 | <dt class="option-term" id="option-cargo-test---manifest-path"><a class="option-anchor" href="#option-cargo-test---manifest-path"></a><code>--manifest-path</code> <em>path</em></dt> | |
339 | <dd class="option-desc">Path to the <code>Cargo.toml</code> file. By default, Cargo searches for the | |
340 | <code>Cargo.toml</code> file in the current directory or any parent directory.</dd> | |
341 | ||
342 | ||
343 | ||
344 | <dt class="option-term" id="option-cargo-test---frozen"><a class="option-anchor" href="#option-cargo-test---frozen"></a><code>--frozen</code></dt> | |
345 | <dt class="option-term" id="option-cargo-test---locked"><a class="option-anchor" href="#option-cargo-test---locked"></a><code>--locked</code></dt> | |
346 | <dd class="option-desc">Either of these flags requires that the <code>Cargo.lock</code> file is | |
347 | up-to-date. If the lock file is missing, or it needs to be updated, Cargo will | |
348 | exit with an error. The <code>--frozen</code> flag also prevents Cargo from | |
349 | attempting to access the network to determine if it is out-of-date.</p> | |
350 | <p>These may be used in environments where you want to assert that the | |
351 | <code>Cargo.lock</code> file is up-to-date (such as a CI build) or want to avoid network | |
352 | access.</dd> | |
353 | ||
354 | ||
355 | <dt class="option-term" id="option-cargo-test---offline"><a class="option-anchor" href="#option-cargo-test---offline"></a><code>--offline</code></dt> | |
356 | <dd class="option-desc">Prevents Cargo from accessing the network for any reason. Without this | |
357 | flag, Cargo will stop with an error if it needs to access the network and | |
358 | the network is not available. With this flag, Cargo will attempt to | |
359 | proceed without the network if possible.</p> | |
360 | <p>Beware that this may result in different dependency resolution than online | |
361 | mode. Cargo will restrict itself to crates that are downloaded locally, even | |
362 | if there might be a newer version as indicated in the local copy of the index. | |
363 | See the <a href="https://doc.rust-lang.org/cargo/commands/cargo-fetch.md">cargo-fetch(1)</a> command to download dependencies before going | |
364 | offline.</p> | |
365 | <p>May also be specified with the <code>net.offline</code> <a href="https://doc.rust-lang.org/cargo/reference/config.html">config value</a>.</dd> | |
366 | ||
367 | ||
368 | ||
369 | </dl> | |
370 | ||
371 | ### Common Options | |
372 | ||
373 | <dl> | |
374 | ||
375 | <dt class="option-term" id="option-cargo-test-+toolchain"><a class="option-anchor" href="#option-cargo-test-+toolchain"></a><code>+</code><em>toolchain</em></dt> | |
376 | <dd class="option-desc">If Cargo has been installed with rustup, and the first argument to <code>cargo</code> | |
377 | begins with <code>+</code>, it will be interpreted as a rustup toolchain name (such | |
378 | as <code>+stable</code> or <code>+nightly</code>). | |
379 | See the <a href="https://github.com/rust-lang/rustup/">rustup documentation</a> | |
380 | for more information about how toolchain overrides work.</dd> | |
381 | ||
382 | ||
383 | <dt class="option-term" id="option-cargo-test--h"><a class="option-anchor" href="#option-cargo-test--h"></a><code>-h</code></dt> | |
384 | <dt class="option-term" id="option-cargo-test---help"><a class="option-anchor" href="#option-cargo-test---help"></a><code>--help</code></dt> | |
385 | <dd class="option-desc">Prints help information.</dd> | |
386 | ||
387 | ||
388 | <dt class="option-term" id="option-cargo-test--Z"><a class="option-anchor" href="#option-cargo-test--Z"></a><code>-Z</code> <em>flag</em></dt> | |
389 | <dd class="option-desc">Unstable (nightly-only) flags to Cargo. Run <code>cargo -Z help</code> for details.</dd> | |
390 | ||
391 | ||
392 | </dl> | |
393 | ||
394 | ||
395 | ### Miscellaneous Options | |
396 | ||
397 | The `--jobs` argument affects the building of the test executable but does not | |
398 | affect how many threads are used when running the tests. The Rust test harness | |
399 | includes an option to control the number of threads used: | |
400 | ||
401 | cargo test -j 2 -- --test-threads=2 | |
402 | ||
403 | <dl> | |
404 | ||
405 | <dt class="option-term" id="option-cargo-test--j"><a class="option-anchor" href="#option-cargo-test--j"></a><code>-j</code> <em>N</em></dt> | |
406 | <dt class="option-term" id="option-cargo-test---jobs"><a class="option-anchor" href="#option-cargo-test---jobs"></a><code>--jobs</code> <em>N</em></dt> | |
407 | <dd class="option-desc">Number of parallel jobs to run. May also be specified with the | |
408 | <code>build.jobs</code> <a href="https://doc.rust-lang.org/cargo/reference/config.html">config value</a>. Defaults to | |
409 | the number of CPUs.</dd> | |
410 | ||
411 | ||
412 | ||
413 | </dl> | |
414 | ||
415 | ## PROFILES | |
416 | ||
417 | Profiles may be used to configure compiler options such as optimization levels | |
418 | and debug settings. See [the reference](../reference/profiles.html) for more | |
419 | details. | |
420 | ||
421 | Profile selection depends on the target and crate being built. By default the | |
422 | `dev` or `test` profiles are used. If the `--release` flag is given, then the | |
423 | `release` or `bench` profiles are used. | |
424 | ||
425 | Target | Default Profile | `--release` Profile | |
426 | -------|-----------------|--------------------- | |
427 | lib, bin, example | `dev` | `release` | |
428 | test, bench, or any target in "test" or "bench" mode | `test` | `bench` | |
429 | ||
430 | Dependencies use the `dev`/`release` profiles. | |
431 | ||
432 | ||
433 | Unit tests are separate executable artifacts which use the `test`/`bench` | |
434 | profiles. Example targets are built the same as with `cargo build` (using the | |
435 | `dev`/`release` profiles) unless you are building them with the test harness | |
436 | (by setting `test = true` in the manifest or using the `--example` flag) in | |
437 | which case they use the `test`/`bench` profiles. Library targets are built | |
438 | with the `dev`/`release` profiles when linked to an integration test, binary, | |
439 | or doctest. | |
440 | ||
441 | ## ENVIRONMENT | |
442 | ||
443 | See [the reference](../reference/environment-variables.html) for | |
444 | details on environment variables that Cargo reads. | |
445 | ||
446 | ||
447 | ## EXIT STATUS | |
448 | ||
449 | * `0`: Cargo succeeded. | |
450 | * `101`: Cargo failed to complete. | |
451 | ||
452 | ||
453 | ## EXAMPLES | |
454 | ||
455 | 1. Execute all the unit and integration tests of the current package: | |
456 | ||
457 | cargo test | |
458 | ||
459 | 2. Run only tests whose names match against a filter string: | |
460 | ||
461 | cargo test name_filter | |
462 | ||
463 | 3. Run only a specific test within a specific integration test: | |
464 | ||
465 | cargo test --test int_test_name -- modname::test_name | |
466 | ||
467 | ## SEE ALSO | |
468 | [cargo(1)](cargo.md), [cargo-bench(1)](cargo-bench.md) |