Skip to content

Commit

Permalink
docs: Add style guide for cargo tests (MaterializeInc#16250)
Browse files Browse the repository at this point in the history
This commit adds a section to the style guide for cargo tests.
  • Loading branch information
jkosh44 authored Dec 5, 2022
1 parent 8572c43 commit 04c38f7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/developer/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ They are named different as to avoid clashing with inherent methods.
These functions require a closure that produces a _name_ for the task, to improve the use of
[`tokio-console`]

### Test-specific

You should prefer to panic in tests rather than returning an error. Tests that return errors
do not produce useful backtraces and instead just point to the line in libtest that asserts
that the test didn't return an error. Panics will produce useful backtraces that include
the line where the panic occurred. This is especially useful for debugging flaky tests in CI.

[Clippy]: https://github.com/rust-lang/rust-clippy
[rustfmt]: https://github.com/rust-lang/rustfmt
[rust-api]: https://rust-lang.github.io/api-guidelines/
Expand Down

0 comments on commit 04c38f7

Please sign in to comment.