You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cargo-mutants can be configured to generate mutants that return an error value from functions that return a Result.
4
+
5
+
This will flag cases where no test fails if the function returns an error: that might happen if there are _only_ tests for the error cases and not for the Ok case.
6
+
7
+
Since crates can choose to use any type for their error values,
8
+
cargo-mutants must be told how to construct an appropriate error.
9
+
10
+
The `--error` command line option and the `error_value` configuration option specify an error value to use.
11
+
12
+
These options can be repeated or combined, which might be useful
13
+
if there are multiple error types in the crate. On any one mutation site, probably only one of the error values will be viable, and cargo-mutants will discover that and use it.
14
+
15
+
The error value can be any Rust expression that evaluates to a value of the error type. It should not include the `Err` wrapper, because cargo-mutants will add that.
16
+
17
+
For example, if your crate uses `anyhow::Error` as its error type, you might use `--error '::anyhow::anyhow!("error")'`.
18
+
19
+
If you have your own error type, you might use `--error 'crate::MyError::Generic'`.
20
+
21
+
Since the correct error type is a property of the source tree, the configuration should typically go into `.cargo/mutants.toml` rather than being specified on the command line:
22
+
23
+
```toml
24
+
error_values = ["::anyhow::anyhow!(\"mutated\")"]
25
+
```
26
+
27
+
To see only the mutants generated by this configuration, you
0 commit comments