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
Copy file name to clipboardExpand all lines: modules/contributor/pages/code-style-guide.adoc
+55-1Lines changed: 55 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -296,7 +296,7 @@ The usage of `thiserror` is considered invalid.
296
296
----
297
297
#[derive(Snafu)]
298
298
enum Error {
299
-
#[snafu(display("failed to read config file of user {user_name}"))]
299
+
#[snafu(display("failed to read config file of user {user_name:?}"))]
300
300
FileRead {
301
301
source: std::io::Error,
302
302
user_name: String,
@@ -595,3 +595,57 @@ let memory: CpuQuantity = "2".parse();
595
595
----
596
596
597
597
====
598
+
599
+
== Writing tests
600
+
601
+
=== Unit test function names
602
+
603
+
Function names of unit tests must not include the `test_` prefix, because otherwise `cargo test` will produce superfluous output like `memory::test::test_addition::case_1`.
604
+
Instead, use an appropriate name to describe what is being tested.
605
+
The previously mentioned name could for example be renamed to `memory::test::addition::case_1`.
606
+
607
+
[TIP.code-rule,caption=Examples of correct code for this rule]
608
+
====
609
+
610
+
[source,rust]
611
+
----
612
+
#[cfg(test)]
613
+
mod test {
614
+
use super::*;
615
+
616
+
#[test]
617
+
fn parse_valid_api_version() {
618
+
todo!()
619
+
}
620
+
621
+
#[test]
622
+
fn parse_invalid_api_version() {
623
+
todo!()
624
+
}
625
+
}
626
+
----
627
+
628
+
====
629
+
630
+
[WARNING.code-rule,caption=Examples of incorrect code for this rule]
0 commit comments